Esempio n. 1
0
func runCProxy(tun *os.File, conn *os.File, ctl *os.File, tunIP ip.IP4, tunMTU uint) {
	var log_errors int
	if log.V(1) {
		log_errors = 1
	}

	C.run_proxy(
		C.int(tun.Fd()),
		C.int(conn.Fd()),
		C.int(ctl.Fd()),
		C.in_addr_t(tunIP.NetworkOrder()),
		C.size_t(tunMTU),
		C.int(log_errors),
	)
}
Esempio n. 2
0
func (r *Router) SetRoute(sn ip.IP4Net, dst ip.IP4) {
	r.mux.Lock()
	defer r.mux.Unlock()

	for _, re := range r.routes {
		if re.sn.Equal(sn) {
			re.addr = &net.UDPAddr{
				IP:   dst.ToIP(),
				Port: r.port,
			}
			return
		}
	}

	re := routeEntry{
		sn: sn,
		addr: &net.UDPAddr{
			IP:   dst.ToIP(),
			Port: r.port,
		},
	}

	r.routes = append(r.routes, re)
}