Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-unixfs
Commits
7a3e0cdc
Commit
7a3e0cdc
authored
Jan 19, 2015
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CR updates to go-reuseport + go-sockaddr
parent
e59b88da
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
24 deletions
+23
-24
Godeps/Godeps.json
Godeps/Godeps.json
+2
-2
Godeps/_workspace/src/github.com/jbenet/go-reuseport/README.md
...s/_workspace/src/github.com/jbenet/go-reuseport/README.md
+1
-1
Godeps/_workspace/src/github.com/jbenet/go-reuseport/impl_unix.go
...workspace/src/github.com/jbenet/go-reuseport/impl_unix.go
+1
-2
Godeps/_workspace/src/github.com/jbenet/go-sockaddr/net/net.go
...s/_workspace/src/github.com/jbenet/go-sockaddr/net/net.go
+19
-19
No files found.
Godeps/Godeps.json
View file @
7a3e0cdc
...
...
@@ -160,11 +160,11 @@
},
{
"ImportPath"
:
"github.com/jbenet/go-reuseport"
,
"Rev"
:
"f
08ef6913526113c76e12e059ffe1b93319a7a18
"
"Rev"
:
"f
2ab96a83e1b33b66478eedd314884755d771933
"
},
{
"ImportPath"
:
"github.com/jbenet/go-sockaddr/net"
,
"Rev"
:
"
47
da30
afb462a74cfc7f3df73d4e5cb1bc42b7c7
"
"Rev"
:
"da30
4f94eea1af8ba8d1faf184623e1f9d9777dc
"
},
{
"ImportPath"
:
"github.com/jbenet/go-temp-err-catcher"
,
...
...
Godeps/_workspace/src/github.com/jbenet/go-reuseport/README.md
View file @
7a3e0cdc
# go-reuseport
![
travisbadge
](
https://travis-ci.org/jbenet/go-reuseport.svg
)
[
![travisbadge
](
https://travis-ci.org/jbenet/go-reuseport.svg
)
](https://travis-ci.org/jbenet/go-reuseport)
This package enables listening and dialing from _the same_ TCP or UDP port.
This means that the following sockopts are set:
...
...
Godeps/_workspace/src/github.com/jbenet/go-reuseport/impl_unix.go
View file @
7a3e0cdc
...
...
@@ -13,8 +13,6 @@ import (
)
const
(
tcp4
=
52
// "4"
tcp6
=
54
// "6"
filePrefix
=
"port."
)
...
...
@@ -305,6 +303,7 @@ func listenUDP(netw, addr string) (c net.Conn, err error) {
return
c
,
err
}
// this is close to the connect() function inside stdlib/net
func
connect
(
fd
int
,
ra
syscall
.
Sockaddr
)
error
{
switch
err
:=
syscall
.
Connect
(
fd
,
ra
);
err
{
case
syscall
.
EINPROGRESS
,
syscall
.
EALREADY
,
syscall
.
EINTR
:
...
...
Godeps/_workspace/src/github.com/jbenet/go-sockaddr/net/net.go
View file @
7a3e0cdc
...
...
@@ -10,9 +10,6 @@ import (
// returns AF_UNSPEC if unknown
func
NetAddrAF
(
addr
net
.
Addr
)
int
{
switch
addr
:=
addr
.
(
type
)
{
default
:
return
AF_UNSPEC
case
*
net
.
IPAddr
:
return
IPAF
(
addr
.
IP
)
...
...
@@ -24,6 +21,9 @@ func NetAddrAF(addr net.Addr) int {
case
*
net
.
UnixAddr
:
return
AF_UNIX
default
:
return
AF_UNSPEC
}
}
...
...
@@ -31,14 +31,14 @@ func NetAddrAF(addr net.Addr) int {
// returns AF_UNSPEC if unknown
func
IPAF
(
ip
net
.
IP
)
int
{
switch
{
default
:
return
AF_UNSPEC
case
ip
.
To4
()
!=
nil
:
return
AF_INET
case
ip
.
To16
()
!=
nil
:
return
AF_INET6
default
:
return
AF_UNSPEC
}
}
...
...
@@ -46,9 +46,6 @@ func IPAF(ip net.IP) int {
// returns -1 if protocol unknown
func
NetAddrIPPROTO
(
addr
net
.
Addr
)
int
{
switch
addr
:=
addr
.
(
type
)
{
default
:
return
-
1
case
*
net
.
IPAddr
:
switch
{
default
:
...
...
@@ -66,6 +63,9 @@ func NetAddrIPPROTO(addr net.Addr) int {
case
*
net
.
UDPAddr
:
return
IPPROTO_UDP
default
:
return
-
1
}
}
...
...
@@ -73,8 +73,6 @@ func NetAddrIPPROTO(addr net.Addr) int {
// returns 0 if type unknown
func
NetAddrSOCK
(
addr
net
.
Addr
)
int
{
switch
addr
:=
addr
.
(
type
)
{
default
:
return
0
case
*
net
.
IPAddr
:
return
SOCK_DGRAM
case
*
net
.
TCPAddr
:
...
...
@@ -92,6 +90,8 @@ func NetAddrSOCK(addr net.Addr) int {
case
"unixpacket"
:
return
SOCK_SEQPACKET
}
default
:
return
0
}
}
...
...
@@ -99,8 +99,6 @@ func NetAddrSOCK(addr net.Addr) int {
// Returns nil if the input is invalid or conversion is not possible.
func
NetAddrToSockaddr
(
addr
net
.
Addr
)
syscall
.
Sockaddr
{
switch
addr
:=
addr
.
(
type
)
{
default
:
return
nil
case
*
net
.
IPAddr
:
return
IPAddrToSockaddr
(
addr
)
case
*
net
.
TCPAddr
:
...
...
@@ -110,6 +108,8 @@ func NetAddrToSockaddr(addr net.Addr) syscall.Sockaddr {
case
*
net
.
UnixAddr
:
sa
,
_
:=
UnixAddrToSockaddr
(
addr
)
return
sa
default
:
return
nil
}
}
...
...
@@ -145,14 +145,14 @@ func IPAddrToSockaddr(addr *net.IPAddr) syscall.Sockaddr {
func
TCPAddrToSockaddr
(
addr
*
net
.
TCPAddr
)
syscall
.
Sockaddr
{
sa
:=
IPAndZoneToSockaddr
(
addr
.
IP
,
addr
.
Zone
)
switch
sa
:=
sa
.
(
type
)
{
default
:
return
nil
case
*
syscall
.
SockaddrInet4
:
sa
.
Port
=
addr
.
Port
return
sa
case
*
syscall
.
SockaddrInet6
:
sa
.
Port
=
addr
.
Port
return
sa
default
:
return
nil
}
}
...
...
@@ -161,14 +161,14 @@ func TCPAddrToSockaddr(addr *net.TCPAddr) syscall.Sockaddr {
func
UDPAddrToSockaddr
(
addr
*
net
.
UDPAddr
)
syscall
.
Sockaddr
{
sa
:=
IPAndZoneToSockaddr
(
addr
.
IP
,
addr
.
Zone
)
switch
sa
:=
sa
.
(
type
)
{
default
:
return
nil
case
*
syscall
.
SockaddrInet4
:
sa
.
Port
=
addr
.
Port
return
sa
case
*
syscall
.
SockaddrInet6
:
sa
.
Port
=
addr
.
Port
return
sa
default
:
return
nil
}
}
...
...
@@ -178,14 +178,14 @@ func UDPAddrToSockaddr(addr *net.UDPAddr) syscall.Sockaddr {
func
UnixAddrToSockaddr
(
addr
*
net
.
UnixAddr
)
(
syscall
.
Sockaddr
,
int
)
{
t
:=
0
switch
addr
.
Net
{
default
:
return
nil
,
0
case
"unix"
:
t
=
syscall
.
SOCK_STREAM
case
"unixgram"
:
t
=
syscall
.
SOCK_DGRAM
case
"unixpacket"
:
t
=
syscall
.
SOCK_SEQPACKET
default
:
return
nil
,
0
}
return
&
syscall
.
SockaddrUnix
{
Name
:
addr
.
Name
},
t
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment