tor-dam

tor distributed announce mechanism (not a dht)
git clone https://git.parazyd.org/tor-dam
Log | Files | Refs | README | LICENSE

gource.go (1421B)


      1 package main
      2 
      3 /*
      4  * Copyright (c) 2017-2021 Ivan Jelincic <parazyd@dyne.org>
      5  *
      6  * This file is part of tor-dam
      7  *
      8  * This program is free software: you can redistribute it and/or modify
      9  * it under the terms of the GNU Affero General Public License as published by
     10  * the Free Software Foundation, either version 3 of the License, or
     11  * (at your option) any later version.
     12  *
     13  * This program is distributed in the hope that it will be useful,
     14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16  * GNU Affero General Public License for more details.
     17  *
     18  * You should have received a copy of the GNU Affero General Public License
     19  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
     20  */
     21 
     22 import (
     23 	"context"
     24 	"flag"
     25 	"fmt"
     26 	"log"
     27 
     28 	"github.com/go-redis/redis"
     29 )
     30 
     31 var (
     32 	redisAddr = flag.String("-r", "127.0.0.1:39148", "host:port for redis")
     33 	rctx      = context.Background()
     34 	rcli      *redis.Client
     35 )
     36 
     37 func main() {
     38 	flag.Parse()
     39 
     40 	rcli = redis.NewClient(&redis.Options{
     41 		Addr:     *redisAddr,
     42 		Password: "",
     43 		DB:       0,
     44 	})
     45 
     46 	// "tordam" is the hardcoded name of the channel
     47 	pubsub := rcli.Subscribe(rctx, "tordam")
     48 	_, err := pubsub.Receive(rctx)
     49 	if err != nil {
     50 		log.Fatal(err)
     51 	}
     52 
     53 	log.Println("Subscribed to channel in redis")
     54 
     55 	ch := pubsub.Channel()
     56 	for msg := range ch {
     57 		fmt.Println(msg.Payload)
     58 	}
     59 }