Alrighty, deploy
continuous-integration/drone/push Build was killed Details

This commit is contained in:
DutchEllie 2022-05-29 20:39:38 +02:00
parent ca847a2bd9
commit c09df22543
Signed by: DutchEllie
SSH Key Fingerprint: SHA256:UU8yhd1Bh8exU88ev0ej/Dm+CeyfR/ZIDRrpRfYdfbg
2 changed files with 2 additions and 24 deletions

View File

@ -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.

View File

@ -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()))