Skip to content

Commit

Permalink
fix styling issues
Browse files Browse the repository at this point in the history
  • Loading branch information
munna0908 committed Jan 7, 2025
1 parent feb1312 commit b387b6a
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion codex/codex.nim
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ proc start*(s: CodexServer) {.async.} =

await s.codexNode.switch.start()

let (announceAddrs,discoveryAddrs)= natedAddress(
let (announceAddrs,discoveryAddrs)= nattedAddress(
s.config.nat,
s.codexNode.switch.peerInfo.addrs,
s.config.discoveryPort)
Expand Down
2 changes: 1 addition & 1 deletion codex/conf.nim
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import ./utils
import ./nat
from ./validationconfig import MaxSlots, ValidationGroups

export units, net, codextypes, logutils,completeCmdArg,parseCmdArg,NatConfig
export units, net, codextypes, logutils, completeCmdArg, parseCmdArg, NatConfig
export ValidationGroups, MaxSlots

export
Expand Down
2 changes: 1 addition & 1 deletion codex/nat.nim
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ proc setupAddress*(natConfig: NatConfig, bindIp: ValidIpAddress,
of NatStrategy.NatUpnp, NatStrategy.NatPmp:
return setupNat(natConfig.nat, tcpPort, udpPort, clientId)

proc natedAddress*(natConfig: NatConfig, addrs: seq[MultiAddress], udpPort: Port): tuple[libp2p, discovery: seq[MultiAddress]] =
proc nattedAddress*(natConfig: NatConfig, addrs: seq[MultiAddress], udpPort: Port): tuple[libp2p, discovery: seq[MultiAddress]] =
## Takes a NAT configuration, sequence of multiaddresses and UDP port and returns:
## - Modified multiaddresses with NAT-mapped addresses for libp2p
## - Discovery addresses with NAT-mapped UDP ports
Expand Down
9 changes: 2 additions & 7 deletions codex/utils/addrutils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,8 @@ proc getMultiAddrWithIPAndUDPPort*(ip: ValidIpAddress, port: Port): MultiAddress
## Returns:
## A MultiAddress in the format "/ip4/<address>/udp/<port>" or "/ip6/<address>/udp/<port>"

let ipFamily = ip.family
if ipFamily == IpAddressFamily.IPv4:
# Construct IPv4 multiaddress
return MultiAddress.init("/ip4/" & $ip & "/udp/" & $port).expect("valid multiaddr")
else:
# Construct IPv6 multiaddress
return MultiAddress.init("/ip6/" & $ip & "/udp/" & $port).expect("valid multiaddr")
let ipFamily = if ip.family == IpAddressFamily.IPv4: "/ip4/" else: "/ip6/"
return MultiAddress.init(ipFamily & $ip & "/udp/" & $port).expect("valid multiaddr")

proc getAddressAndPort*(ma: MultiAddress): tuple[ip: Option[ValidIpAddress], port: Option[Port]] =
try:
Expand Down
4 changes: 2 additions & 2 deletions tests/codex/testnat.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import ../../codex/utils


suite "NAT Address Tests":
test "natedAddress with local addresses":
test "nattedAddress with local addresses":
# Setup test data
let
udpPort = Port(1234)
Expand Down Expand Up @@ -39,7 +39,7 @@ suite "NAT Address Tests":
addrs = @[localAddr, anyAddr, publicAddr]

# Test address remapping
let (libp2pAddrs,discoveryAddrs) = natedAddress(natConfig, addrs, udpPort)
let (libp2pAddrs,discoveryAddrs) = nattedAddress(natConfig, addrs, udpPort)

# Verify results
check(discoveryAddrs == expectedDiscoveryAddrs)
Expand Down

0 comments on commit b387b6a

Please sign in to comment.