From c09df225438f73a8aa35f1f4e6e11b5f7a0b220b Mon Sep 17 00:00:00 2001 From: DutchEllie Date: Sun, 29 May 2022 20:39:38 +0200 Subject: [PATCH] Alrighty, deploy --- README.md | 2 ++ src/main.go | 24 ------------------------ 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 6497659..375ffe7 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Proper-website p2p API +[![Build Status](https://drone.dutchellie.nl/api/badges/DutchEllie/proper-website-p2p-api/status.svg?ref=refs/heads/main)](https://drone.dutchellie.nl/DutchEllie/proper-website-p2p-api) + The p2p part of the proper-website API. Designed specifically to be ephemeral, and scalable. As long as one node is online, it should be fine I think. diff --git a/src/main.go b/src/main.go index 4ef6d93..f355cdd 100644 --- a/src/main.go +++ b/src/main.go @@ -1,14 +1,12 @@ package main import ( - "bufio" "context" "fmt" "log" "github.com/libp2p/go-libp2p" "github.com/libp2p/go-libp2p-core/host" - "github.com/libp2p/go-libp2p-core/network" relayv1 "github.com/libp2p/go-libp2p/p2p/protocol/circuitv1/relay" libp2pquic "github.com/libp2p/go-libp2p/p2p/transport/quic" "github.com/libp2p/go-libp2p/p2p/transport/tcp" @@ -56,28 +54,6 @@ func run() { return } - h1.SetStreamHandler("/echo/1.0.0", func(s network.Stream) { - log.Println("listener received new stream") - - // Read whatever comes in and print it out - // from https://github.com/libp2p/go-libp2p/blob/621eafcecde611b27bbb42dda4b8bbc97b66e907/examples/echo/main.go#L197 - if err := func(s network.Stream) error { - buf := bufio.NewReader(s) - str, err := buf.ReadString('\n') - if err != nil { - log.Printf("error reading stream: %v\n", err) - return err - } - log.Printf("read: %s", str) - _, err = s.Write([]byte(str)) - return err - }(s); err != nil { - log.Println(err) - s.Reset() - } else { - s.Close() - } - }) fullAddr := func(ha host.Host) string { // Build host multiaddress hostAddr, _ := ma.NewMultiaddr(fmt.Sprintf("/p2p/%s", ha.ID().Pretty()))