mirror of
https://github.com/fumiama/WireGold.git
synced 2026-06-12 21:00:27 +08:00
fix: listen at print
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
|
"net/netip"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
@@ -18,10 +19,11 @@ import (
|
|||||||
|
|
||||||
// 监听本机 endpoint
|
// 监听本机 endpoint
|
||||||
func (m *Me) listen() (conn *net.UDPConn, err error) {
|
func (m *Me) listen() (conn *net.UDPConn, err error) {
|
||||||
conn, err = net.ListenUDP("udp", m.myend)
|
conn, err = net.ListenUDP("udp", net.UDPAddrFromAddrPort(netip.MustParseAddrPort(m.myend.String())))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
m.myend = conn.LocalAddr()
|
||||||
logrus.Infoln("[listen] at", m.myend)
|
logrus.Infoln("[listen] at", m.myend)
|
||||||
var mu sync.Mutex
|
var mu sync.Mutex
|
||||||
for i := 0; i < runtime.NumCPU()*4; i++ {
|
for i := 0; i < runtime.NumCPU()*4; i++ {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ type Me struct {
|
|||||||
// 本机子网
|
// 本机子网
|
||||||
subnet net.IPNet
|
subnet net.IPNet
|
||||||
// 本机 endpoint
|
// 本机 endpoint
|
||||||
myend *net.UDPAddr
|
myend net.Addr
|
||||||
// 本机环回 link
|
// 本机环回 link
|
||||||
loop *Link
|
loop *Link
|
||||||
// 本机活跃的所有连接
|
// 本机活跃的所有连接
|
||||||
|
|||||||
Reference in New Issue
Block a user