main.go (1258B)
1 package main 2 3 /* 4 * Copyright (c) 2018 Dyne.org Foundation 5 * tor-dam is written and maintained by Ivan Jelincic <parazyd@dyne.org> 6 * 7 * This file is part of tor-dam 8 * 9 * This program is free software: you can redistribute it and/or modify 10 * it under the terms of the GNU Affero General Public License as published by 11 * the Free Software Foundation, either version 3 of the License, or 12 * (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU Affero General Public License for more details. 18 * 19 * You should have received a copy of the GNU Affero General Public License 20 * along with this program. If not, see <http://www.gnu.org/licenses/>. 21 */ 22 23 import ( 24 "fmt" 25 "os" 26 27 lib "github.com/parazyd/tor-dam/pkg/damlib" 28 ) 29 30 func main() { 31 pubsub := lib.RedisCli.Subscribe(lib.Rctx, lib.PubSubChan) 32 _, err := pubsub.Receive(lib.Rctx) 33 lib.CheckError(err) 34 fmt.Fprintf(os.Stderr, "Subscribed to %s channel in Redis\n", lib.PubSubChan) 35 36 ch := pubsub.Channel() 37 38 fmt.Fprintf(os.Stderr, "Listening to messages...\n") 39 for msg := range ch { 40 fmt.Println(msg.Payload) 41 } 42 }