/usr/share/gocode/src/github.com/linuxkit/virtsock/cmd/sock_stress/unix.go is in golang-github-linuxkit-virtsock-dev 0.0~git20170720.0.0416e3d-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | package main
import (
"log"
"net"
"os"
)
type unixAddr struct {
addr string
}
func unixParseSockStr(sockStr string) unixAddr {
return unixAddr{addr: sockStr}
}
func (s unixAddr) String() string {
return "unix" + "://" + s.addr
}
// Dial connects on a unix domain socket
func (s unixAddr) Dial(conid int) (Conn, error) {
c, err := net.Dial("unix", s.addr)
if err != nil {
return nil, err
}
return c.(*net.UnixConn), err
}
// Listen returns a net.Listener for a given unix domain socket
// Note, this creates the file, but does not remove it on exit. Should
// be fine for our purpose
func (s unixAddr) Listen() net.Listener {
os.Remove(s.addr)
l, err := net.Listen("unix", s.addr)
if err != nil {
log.Fatalln("Listen():", err)
}
return l
}
// ListenPacket is not implemented for unix domain sockets
func (s unixAddr) ListenPacket() net.PacketConn {
log.Fatalln("ListenPacket(): not implemented for unix domain sockets")
return nil
}
|