Skip to content

Commit

Permalink
interface_darwin.go code cleanup & remove OS X support from the roadm…
Browse files Browse the repository at this point in the history
…ap since it now works properly on OS X
  • Loading branch information
wxdao committed Mar 13, 2017
1 parent b3d95d0 commit 9a7e4a6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 49 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Full video can be found at https://www.youtube.com/watch?v=sW5ZIcfX7w8
## Roadmap

1. Better encryption
2. Windows/OSx support
2. Windows support
3. IPv6
4. Much more
5. IP Load Balancing
Expand Down
49 changes: 1 addition & 48 deletions network/interface_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"net"
"os/exec"
"strconv"
"strings"
"syscall"
)

Expand Down Expand Up @@ -77,28 +76,7 @@ func (a *UTUNAccess) Read(data []byte) (n int, err error) {
return
}

const (
cIFF_TUN = 0x0001
cIFF_TAP = 0x0002
cIFF_NO_PI = 0x1000
)

type ifReq struct {
Name [0x10]byte
Flags uint16
pad [0x28 - 0x10 - 2]byte
}

func newTAP(ifName string) (ifce *Interface, err error) {
// file, err := os.OpenFile("/dev/net/tun", os.O_RDWR, 0)
// if err != nil {
// return nil, err
// }
// name, err := createInterface(file.Fd(), ifName, cIFF_TAP|cIFF_NO_PI)
// if err != nil {
// return nil, err
// }
// ifce = &Interface{isTAP: true, file: file, name: name}
err = errors.New("unsupported")
return
}
Expand All @@ -111,24 +89,8 @@ func newTUN(ifName string) (ifce *Interface, err error) {
return ifce, nil
}

func createInterface(fd uintptr, ifName string, flags uint16) (createdIFName string, err error) {
var req ifReq
req.Flags = flags
copy(req.Name[:], ifName)
createdIFName = strings.Trim(string(req.Name[:]), "\x00")
return
}

func setPersistent(fd uintptr, persistent bool) error {
// var val uintptr = 0
// if persistent {
// val = 1
// }
// _, _, errno := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(syscall.TUNSETPERSIST), val)
// if errno != 0 {
// return errno
// }
return nil
return errors.New("unsupported")
}

func interfaceOpen(ifType, ifName string) (*Interface, error) {
Expand All @@ -146,15 +108,6 @@ func interfaceOpen(ifType, ifName string) (*Interface, error) {
ifce.name = fmt.Sprintf("utun%d", i)
ifce.file = &UTUNAccess{fd: int(fd)}
break

//ifPath := fmt.Sprintf("/dev/%s%d", ifType, i)
//fmt.Println(ifPath)
//ifce.file, err = os.OpenFile(ifPath, os.O_RDWR, 0)
//if err != nil {
// continue
//}
//ifce.name = fmt.Sprintf("%s%d", ifType, i)
//break
}
return ifce, err
}
Expand Down

0 comments on commit 9a7e4a6

Please sign in to comment.