use & instead of fmt

This commit is contained in:
Christian Ulrich 2020-10-23 01:21:19 +02:00
parent 70778f972e
commit 287e344779
No known key found for this signature in database
GPG Key ID: 8241BE099775A097
3 changed files with 5 additions and 6 deletions

View File

@ -239,7 +239,7 @@ proc runApp(serverHostname: string, serverPort: Port, peerId: string,
srcPort) srcPort)
asyncCheck handleServerMessages(serverConn) asyncCheck handleServerMessages(serverConn)
let sock = await punchHole(punchdConn, serverConn, peerId, otherPeerId, let sock = await punchHole(punchdConn, serverConn, peerId, otherPeerId,
"tcp-nutss") "tcp-syni")
echo "connected!" echo "connected!"
await sock.send("ping") await sock.send("ping")
let msg = await sock.recv(4) let msg = await sock.recv(4)

View File

@ -136,7 +136,7 @@ proc serve(port: Port) {.async.} =
proc main() = proc main() =
if paramCount() != 1: if paramCount() != 1:
echo(fmt"usage: {paramStr(0)} PORT") echo(&"usage: {paramStr(0)} PORT")
quit(1) quit(1)
try: try:

View File

@ -54,8 +54,7 @@ method respond*(puncher: Responder, args: string):
proc makeFirewallRule(srcIp: IpAddress, srcPort: Port, proc makeFirewallRule(srcIp: IpAddress, srcPort: Port,
dstIp: IpAddress, dstPort: Port): string = dstIp: IpAddress, dstPort: Port): string =
# FIXME: use & instead of fmt? result = &"""-w \
result = fmt"""-w \
-d {srcIp} \ -d {srcIp} \
-p icmp \ -p icmp \
--icmp-type time-exceeded \ --icmp-type time-exceeded \
@ -69,11 +68,11 @@ proc makeFirewallRule(srcIp: IpAddress, srcPort: Port,
-j DROP""" -j DROP"""
proc iptablesInsert(chain: string, rule: string) {.async.} = proc iptablesInsert(chain: string, rule: string) {.async.} =
let firewall_cmd = fmt"iptables -I {chain} {rule}" let firewall_cmd = &"iptables -I {chain} {rule}"
discard await asyncExecCmd(firewall_cmd) discard await asyncExecCmd(firewall_cmd)
proc iptablesDelete(chain: string, rule: string) {.async.} = proc iptablesDelete(chain: string, rule: string) {.async.} =
let firewall_cmd = fmt"iptables -D {chain} {rule}" let firewall_cmd = &"iptables -D {chain} {rule}"
discard await asyncExecCmd(firewall_cmd) discard await asyncExecCmd(firewall_cmd)
proc addFirewallRules*(attempt: Attempt) {.async.} = proc addFirewallRules*(attempt: Attempt) {.async.} =