things-go / go-socks5

socks5 server in pure Golang with much custom optional. Full TCP/UDP and IPv4/IPv6 support.
MIT License
409 stars 71 forks source link

BUG: splice: bad file descriptor #73

Open ne1llee opened 1 month ago

ne1llee commented 1 month ago

The sock5 proxy service running on a device with armv7l and linux kernel version 3.10.39 cannot be accessed normally.

server: writeto tcp 192.168.1.44:38851->74.125.24.104:80: readfrom tcp4 192.168.1.44:1080->46.12.112.133:33248: splice: bad file descriptor
thinkgos commented 1 month ago

show the minimum code that can reproduce the problem

ne1llee commented 1 month ago

Quote reply Refere


func (p *Sock5) Start() error {
    if p.status == plugins.Running {
        return fmt.Errorf("is already running")
    }

    var options []socks5.Option
    options = append(options, socks5.WithLogger(socks5.NewLogger(p.logger)))

    if p.username != "" && p.password != "" {
        cator := socks5.UserPassAuthenticator{Credentials: socks5.StaticCredentials{p.username: p.password}}
        options = append(options, socks5.WithAuthMethods([]socks5.Authenticator{cator}))
    }

    p.server = socks5.NewServer(options...)

    var err error
    p.listener, err = net.Listen("tcp", p.address)
    if err != nil {
        return fmt.Errorf("failed to start: %w", err)
    }

    p.ctx, p.cancel = context.WithCancel(context.Background())
    go func() {
        if err := p.server.Serve(p.listener); err != nil {
            fmt.Println("stopped:", err)
        }
    }()
    fmt.Println("started")
    return nil
}
thinkgos commented 1 month ago

this code can't run on my machine