mirror of
https://github.com/sigcn/pg.git
synced 2026-04-22 21:17:04 +08:00
2ff96a4c475102aac3ed830af4c391caf01e5f64
Example
packetConn, err := p2p.ListenPacket(
peer.NetworkID("HXncIcQ4ocsGtOOrQQiG4H2WHXPplZakuq4f6EJR1cg="),
[]string{"wss://synf.in/pg"},
)
if err != nil {
panic(err)
}
for {
buf := make([]byte, 1024)
n, peerID, err := packetConn.ReadFrom(buf)
if err != nil {
panic(err)
}
fmt.Println("Echo packet to", peerID, string(buf[:n]))
_, err = packetConn.WriteTo(peerID, buf[:n])
if err != nil {
panic(err)
}
}
Languages
Go
93.1%
Vue
3.1%
JavaScript
1.8%
CSS
0.9%
Makefile
0.9%
Other
0.2%