Skip to content

Commit

Permalink
Merge pull request #46 from brave/igor/support-unix-socket
Browse files Browse the repository at this point in the history
Unix socket support
  • Loading branch information
ibukanov authored Sep 17, 2024
2 parents 39b3d0a + cdb323b commit b3e0296
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions viproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package viproxy

import (
"fmt"
"io"
"log"
"net"
Expand Down Expand Up @@ -56,6 +57,10 @@ func dial(addr net.Addr) (net.Conn, error) {
conn, err = vsock.Dial(a.ContextID, a.Port, nil)
case *net.TCPAddr:
conn, err = net.DialTCP("tcp", nil, a)
case *net.UnixAddr:
conn, err = net.DialUnix(addr.Network(), nil, a)
default:
return nil, fmt.Errorf("unsupported address type %T", addr)
}
if err != nil {
return nil, err
Expand All @@ -73,6 +78,10 @@ func listen(addr net.Addr) (net.Listener, error) {
ln, err = vsock.ListenContextID(a.ContextID, a.Port, nil)
case *net.TCPAddr:
ln, err = net.ListenTCP(a.Network(), a)
case *net.UnixAddr:
ln, err = net.ListenUnix(addr.Network(), a)
default:
return nil, fmt.Errorf("unsupported address type %T", addr)
}
if err != nil {
return nil, err
Expand Down

0 comments on commit b3e0296

Please sign in to comment.