Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tried Unix Domain Socket backend... #2

Open
gitmko0 opened this issue Nov 11, 2020 · 0 comments
Open

Tried Unix Domain Socket backend... #2

gitmko0 opened this issue Nov 11, 2020 · 0 comments

Comments

@gitmko0
Copy link

gitmko0 commented Nov 11, 2020

Hi, how do i make this work?

It's returning gibberish. Any solutions to make uds work too?


func forwardTcp(conn net.Conn, connectTo string) {
        if debug {
                log.Print("Accepted connection\n")
        }
        //fwd, err := net.DialTimeout("tcp", connectTo, timeout)
        addrunix, err := net.ResolveUnixAddr("unix", connectTo)
        fwd, err := net.DialUnix("unix", nil, addrunix)
        if err != nil {
                log.Printf("Conection to `%s` failed: %v\n", connectTo, err)
                conn.Close()
                return
        }
        close := func() {
                fwd.Close()
                conn.Close()
        }
        go func() {
                defer close()
                w, err := io.Copy(fwd, conn)
                if debug {
                        log.Printf("Incoming TCP connection closed: %v; %v bytes forwarded\n", err, w)
                }
        }()
        go func() {
                defer close()
                w, err := io.Copy(conn, fwd)
                if debug {
                        log.Printf("Outgoing TCP connection closed: %v; %v bytes forwarded\n", err, w)
                }
        }()
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant