Skip to content

Tried Unix Domain Socket backend... #2

@gitmko0

Description

@gitmko0

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)
                }
        }()
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions