Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
arm64v8a committed Jan 13, 2023
1 parent 1ab3c01 commit 82662c5
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 89 deletions.
4 changes: 2 additions & 2 deletions buildScript/init/action/go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ mkdir -p $GOPATH
cd $golang

if [ ! -f "go/bin/go" ]; then
curl -Lso go.tar.gz https://go.dev/dl/go1.18.8.linux-amd64.tar.gz
echo "4d854c7bad52d53470cf32f1b287a5c0c441dc6b98306dea27358e099698142a go.tar.gz" | sha256sum -c -
curl -Lso go.tar.gz https://go.dev/dl/go1.19.5.linux-amd64.tar.gz
echo "36519702ae2fd573c9869461990ae550c8c0d955cd28d2827a6b159fda81ff95 go.tar.gz" | sha256sum -c -
tar xzf go.tar.gz
fi

Expand Down
2 changes: 1 addition & 1 deletion libcore/core_commit.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4f625c63db754f70cf95b69a9e4a38b33e9e096f
07a3c272a42ce0fe834a645176d663ce3b193e49
2 changes: 1 addition & 1 deletion libcore/date.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
var outdated string

func GetBuildTime() int64 {
buildDate := "20230108"
buildDate := "20230112"
buildTime, _ := time.Parse("20060102", buildDate)
return buildTime.Unix()
}
Expand Down
2 changes: 1 addition & 1 deletion libcore/tun.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ func (t *Tun2ray) udpHandleUplinkInternal(p *tun.UDPPacket) {
}

if info == nil {
logrus.Infof("[%s] %s ==> %s", tag, source.NetAddr(), destination.NetAddr())
logrus.Infof("[%s] [uid:%d] %s ==> %s", tag, uid, source.NetAddr(), destination.NetAddr())
} else {
logrus.Infof("[%s][%s (%d/%s)] %s ==> %s", tag, info.Label, uid, info.PackageName, source.NetAddr(), destination.NetAddr())
}
Expand Down
84 changes: 0 additions & 84 deletions libcore/v2ray_udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,87 +161,3 @@ func (c *dispatcherConn) Close() error {

return nil
}

// udpConn (for go net)

func (instance *V2RayInstance) DialUDP(raddr *net.UDPAddr) (*udpConn, error) {
ctx := core.WithContext(context.Background(), instance.Core)
destination := net2.DestinationFromAddr(raddr)
r, err := instance.Dispatcher.Dispatch(ctx, destination)
if err != nil {
return nil, err
}
return &udpConn{
r.Reader, r.Writer,
}, nil
}

var _ net.PacketConn = (*udpConn)(nil)

type udpConn struct {
reader buf.Reader
writer buf.Writer
}

func (c *udpConn) ReadFrom(p []byte) (int, net.Addr, error) {
mb, err := c.reader.ReadMultiBuffer()
if err != nil {
buf.ReleaseMulti(mb)
return 0, nil, err
}

var n int
var total int
var endpoint net.Addr

for _, buffer := range mb {
if buffer.Len() <= 0 {
buffer.Release()
continue
}

var src net2.Destination
if buffer.Endpoint == nil {
src.Address = net2.AnyIP
} else {
src = *buffer.Endpoint
}
if src.Address.Family().IsDomain() {
src.Address = net2.AnyIP
}
endpoint = &net.UDPAddr{
IP: src.Address.IP(),
Port: int(src.Port.Value()),
}

n, err = buffer.Read(p)
total += n
buffer.Release()

break
}

return total, endpoint, err
}

func (c *udpConn) WriteTo(p []byte, addr net.Addr) (int, error) {
buffer := buf.FromBytes(p)
endpoint := net2.DestinationFromAddr(addr)
buffer.Endpoint = &endpoint
err := c.writer.WriteMultiBuffer(buf.MultiBuffer{buffer})
if err == nil {
return len(p), nil
}
return 0, err
}

func (c *udpConn) Close() error {
common.Close(c.writer)
common.Close(c.reader)
return nil
}

func (c *udpConn) LocalAddr() net.Addr { return &net.UDPAddr{} }
func (c *udpConn) SetDeadline(t time.Time) error { return nil }
func (c *udpConn) SetReadDeadline(t time.Time) error { return nil }
func (c *udpConn) SetWriteDeadline(t time.Time) error { return nil }

0 comments on commit 82662c5

Please sign in to comment.