rename fromIpAddress -> getNetworkInterface
This commit is contained in:
parent
1116d06e82
commit
a646815e49
|
@ -26,7 +26,7 @@ proc getifaddrs(ifap: ptr ptr Ifaddrs): int {.header: "<ifaddrs.h>", importc: "g
|
||||||
proc freeifaddrs(ifap: ptr Ifaddrs): void {.header: "<ifaddrs.h>", importc: "freeifaddrs".}
|
proc freeifaddrs(ifap: ptr Ifaddrs): void {.header: "<ifaddrs.h>", importc: "freeifaddrs".}
|
||||||
proc if_nametoindex(ifname: cstring): cuint {.header: "<net/if.h>", importc: "if_nametoindex".}
|
proc if_nametoindex(ifname: cstring): cuint {.header: "<net/if.h>", importc: "if_nametoindex".}
|
||||||
|
|
||||||
proc fromIpAddress*(address: IpAddress): NetworkInterface =
|
proc getNetworkInterface*(address: IpAddress): NetworkInterface =
|
||||||
var interfaces: ptr Ifaddrs
|
var interfaces: ptr Ifaddrs
|
||||||
if getifaddrs(addr interfaces) != 0:
|
if getifaddrs(addr interfaces) != 0:
|
||||||
raise newException(NetworkInterfaceError, "getifaddrs failed")
|
raise newException(NetworkInterfaceError, "getifaddrs failed")
|
||||||
|
|
|
@ -96,7 +96,7 @@ proc injectTcpPacket(rawFd: AsyncFD, ipPacket: IpPacket) {.async.} =
|
||||||
|
|
||||||
proc captureSeqNumbers(attempt: ConnectAttempt, cb: PunchProgressCb) {.async.} =
|
proc captureSeqNumbers(attempt: ConnectAttempt, cb: PunchProgressCb) {.async.} =
|
||||||
# FIXME: timeout?
|
# FIXME: timeout?
|
||||||
let iface = fromIpAddress(attempt.srcIp)
|
let iface = getNetworkInterface(attempt.srcIp)
|
||||||
let captureFd = setupEthernetCapturingSocket(iface)
|
let captureFd = setupEthernetCapturingSocket(iface)
|
||||||
var seqNums = newSeq[uint32]()
|
var seqNums = newSeq[uint32]()
|
||||||
while seqNums.len < attempt.dstPorts.len:
|
while seqNums.len < attempt.dstPorts.len:
|
||||||
|
@ -117,7 +117,7 @@ proc captureSeqNumbers(attempt: ConnectAttempt, cb: PunchProgressCb) {.async.} =
|
||||||
await cb(seqNums)
|
await cb(seqNums)
|
||||||
|
|
||||||
proc captureAndResendAck(attempt: ConnectAttempt) {.async.} =
|
proc captureAndResendAck(attempt: ConnectAttempt) {.async.} =
|
||||||
let iface = fromIpAddress(attempt.srcIp)
|
let iface = getNetworkInterface(attempt.srcIp)
|
||||||
let captureFd = setupEthernetCapturingSocket(iface)
|
let captureFd = setupEthernetCapturingSocket(iface)
|
||||||
let injectFd = setupTcpInjectingSocket()
|
let injectFd = setupTcpInjectingSocket()
|
||||||
block loops:
|
block loops:
|
||||||
|
|
Loading…
Reference in New Issue