net/dtcp: make dtcp work with Ruby 3.X.
This commit is contained in:
parent
6447a45afe
commit
5f28f9cbd4
3 changed files with 75 additions and 24 deletions
|
@ -1,6 +1,6 @@
|
||||||
PORTNAME= dtcp
|
PORTNAME= dtcp
|
||||||
PORTVERSION= 20130602
|
PORTVERSION= 20130602
|
||||||
PORTREVISION= 3
|
PORTREVISION= 4
|
||||||
CATEGORIES= net
|
CATEGORIES= net
|
||||||
MASTER_SITES= http://www.mahoroba.org/~ume/ipv6/
|
MASTER_SITES= http://www.mahoroba.org/~ume/ipv6/
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
Index: dtcpc.rb
|
--- dtcpc.rb.orig 2013-06-02 14:05:51 UTC
|
||||||
diff -u dtcpc.rb.orig dtcpc.rb
|
+++ dtcpc.rb
|
||||||
--- dtcpc.rb.orig 2013-06-02 23:05:51.000000000 +0900
|
@@ -422,6 +422,10 @@ class Interface
|
||||||
+++ dtcpc.rb 2014-05-22 17:24:50.852383194 +0900
|
|
||||||
@@ -422,6 +422,10 @@
|
|
||||||
execute("ifconfig #{@name} mtu #{mtu}")
|
execute("ifconfig #{@name} mtu #{mtu}")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -13,7 +11,7 @@ diff -u dtcpc.rb.orig dtcpc.rb
|
||||||
def linklocal
|
def linklocal
|
||||||
`ifconfig #{@name} inet6`.each_line { |s|
|
`ifconfig #{@name} inet6`.each_line { |s|
|
||||||
if s =~ /inet6 (fe80::[^ ]*)/
|
if s =~ /inet6 (fe80::[^ ]*)/
|
||||||
@@ -461,6 +465,9 @@
|
@@ -461,6 +465,9 @@ class ClonedInterface < Interface
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -23,7 +21,7 @@ diff -u dtcpc.rb.orig dtcpc.rb
|
||||||
@created = true
|
@created = true
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -520,6 +527,9 @@
|
@@ -520,6 +527,9 @@ class NetgraphInterface < Interface
|
||||||
if !@tunif || @tunif == "ng"
|
if !@tunif || @tunif == "ng"
|
||||||
@name = mkpeer
|
@name = mkpeer
|
||||||
@created = true
|
@created = true
|
||||||
|
@ -33,7 +31,12 @@ diff -u dtcpc.rb.orig dtcpc.rb
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -535,6 +545,9 @@
|
@@ -531,10 +541,13 @@ class NetgraphInterface < Interface
|
||||||
|
shutdown(@tunif)
|
||||||
|
|
||||||
|
bogus = Array.new
|
||||||
|
- while TRUE
|
||||||
|
+ while true
|
||||||
@name = mkpeer
|
@name = mkpeer
|
||||||
if @name == @tunif
|
if @name == @tunif
|
||||||
@created = true
|
@created = true
|
||||||
|
@ -43,7 +46,16 @@ diff -u dtcpc.rb.orig dtcpc.rb
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -927,6 +940,7 @@
|
@@ -899,7 +912,7 @@ class DTCPClient
|
||||||
|
|
||||||
|
def keep_alive(sock)
|
||||||
|
begin
|
||||||
|
- while TRUE
|
||||||
|
+ while true
|
||||||
|
debugmsg("sleep(60)\n")
|
||||||
|
sleep 60
|
||||||
|
sendmsg(sock, "ping")
|
||||||
|
@@ -927,6 +940,7 @@ ousername = username
|
||||||
password = ''
|
password = ''
|
||||||
tunif = TUNIF
|
tunif = TUNIF
|
||||||
cloning = TUNIF_CLONING
|
cloning = TUNIF_CLONING
|
||||||
|
@ -51,7 +63,7 @@ diff -u dtcpc.rb.orig dtcpc.rb
|
||||||
tuntype = 'tunnelonly'
|
tuntype = 'tunnelonly'
|
||||||
route_type = 'static'
|
route_type = 'static'
|
||||||
static_routes = 'default'
|
static_routes = 'default'
|
||||||
@@ -949,7 +963,7 @@
|
@@ -949,7 +963,7 @@ pidfile = PIDFILE
|
||||||
# exit 0
|
# exit 0
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
@ -60,7 +72,7 @@ diff -u dtcpc.rb.orig dtcpc.rb
|
||||||
rescue
|
rescue
|
||||||
usage()
|
usage()
|
||||||
exit 0
|
exit 0
|
||||||
@@ -965,6 +979,7 @@
|
@@ -965,6 +979,7 @@ cloning = false if params["c"]
|
||||||
$debug = params["d"]
|
$debug = params["d"]
|
||||||
daemonize = params["D"]
|
daemonize = params["D"]
|
||||||
pidfile = params["f"] if params["f"]
|
pidfile = params["f"] if params["f"]
|
||||||
|
@ -68,3 +80,12 @@ diff -u dtcpc.rb.orig dtcpc.rb
|
||||||
tunif = params["i"] if params["i"]
|
tunif = params["i"] if params["i"]
|
||||||
loop = params["l"]
|
loop = params["l"]
|
||||||
mtu = params["m"].to_i if params["m"]
|
mtu = params["m"].to_i if params["m"]
|
||||||
|
@@ -1013,7 +1028,7 @@ begin
|
||||||
|
rtadvd_disable)
|
||||||
|
dtcpc = DTCPClient.new(dst, port, username, password, tuntype, behind_nat,
|
||||||
|
mtu, udp_tunnel, udp_tunnel_port)
|
||||||
|
- while TRUE
|
||||||
|
+ while true
|
||||||
|
interrupt = nil
|
||||||
|
begin
|
||||||
|
trap("SIGHUP") {
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
Index: dtcps.rb
|
--- dtcps.rb.orig 2013-06-02 14:05:51 UTC
|
||||||
diff -u dtcps.rb.orig dtcps.rb
|
+++ dtcps.rb
|
||||||
--- dtcps.rb.orig 2013-06-02 23:05:51.000000000 +0900
|
@@ -185,6 +185,18 @@ class Interface
|
||||||
+++ dtcps.rb 2014-05-22 17:24:50.868385076 +0900
|
|
||||||
@@ -185,6 +185,18 @@
|
|
||||||
execute("ifconfig #{@name} mtu #{mtu}")
|
execute("ifconfig #{@name} mtu #{mtu}")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -21,7 +19,7 @@ diff -u dtcps.rb.orig dtcps.rb
|
||||||
def linklocal
|
def linklocal
|
||||||
`ifconfig #{@name} inet6`.each_line { |s|
|
`ifconfig #{@name} inet6`.each_line { |s|
|
||||||
if s =~ /inet6 (fe80::[^ ]*)/
|
if s =~ /inet6 (fe80::[^ ]*)/
|
||||||
@@ -226,6 +238,9 @@
|
@@ -226,6 +238,9 @@ class ClonedInterface < Interface
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -31,7 +29,7 @@ diff -u dtcps.rb.orig dtcps.rb
|
||||||
@created = true
|
@created = true
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -291,6 +306,9 @@
|
@@ -291,6 +306,9 @@ class NetgraphInterface < Interface
|
||||||
if !@tunif || @tunif == "ng"
|
if !@tunif || @tunif == "ng"
|
||||||
@name = mkpeer
|
@name = mkpeer
|
||||||
@created = true
|
@created = true
|
||||||
|
@ -41,7 +39,12 @@ diff -u dtcps.rb.orig dtcps.rb
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -306,6 +324,9 @@
|
@@ -302,10 +320,13 @@ class NetgraphInterface < Interface
|
||||||
|
shutdown(@tunif)
|
||||||
|
|
||||||
|
bogus = Array.new
|
||||||
|
- while TRUE
|
||||||
|
+ while true
|
||||||
@name = mkpeer
|
@name = mkpeer
|
||||||
if @name == @tunif
|
if @name == @tunif
|
||||||
@created = true
|
@created = true
|
||||||
|
@ -51,7 +54,7 @@ diff -u dtcps.rb.orig dtcps.rb
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -724,6 +745,7 @@
|
@@ -724,6 +745,7 @@ class Tunnel
|
||||||
}
|
}
|
||||||
delpeer(@tunif, @info[3], @info[2])
|
delpeer(@tunif, @info[3], @info[2])
|
||||||
end
|
end
|
||||||
|
@ -59,7 +62,7 @@ diff -u dtcps.rb.orig dtcps.rb
|
||||||
_delete(@tunif)
|
_delete(@tunif)
|
||||||
@tunif = nil
|
@tunif = nil
|
||||||
end
|
end
|
||||||
@@ -769,6 +791,7 @@
|
@@ -769,6 +791,7 @@ class Tunnel
|
||||||
raise 'tunnel interface sold out'
|
raise 'tunnel interface sold out'
|
||||||
end
|
end
|
||||||
debugmsg("#{s}: tunnel interface #{tunif.name}\n")
|
debugmsg("#{s}: tunnel interface #{tunif.name}\n")
|
||||||
|
@ -67,7 +70,34 @@ diff -u dtcps.rb.orig dtcps.rb
|
||||||
|
|
||||||
myaddr = nil
|
myaddr = nil
|
||||||
if type == 'host' || (type == 'network' && $network_with_peeraddr)
|
if type == 'host' || (type == 'network' && $network_with_peeraddr)
|
||||||
@@ -1173,13 +1196,14 @@
|
@@ -883,7 +906,7 @@ end
|
||||||
|
def checktraffic(tun)
|
||||||
|
return if TRAFFICTIMEOUT == 0
|
||||||
|
ipkts = getipkts(tun.name)
|
||||||
|
- while TRUE
|
||||||
|
+ while true
|
||||||
|
sleep TRAFFICTIMEOUT
|
||||||
|
i = getipkts(tun.name)
|
||||||
|
next if i == -1
|
||||||
|
@@ -899,7 +922,7 @@ end
|
||||||
|
|
||||||
|
def service_dtcp(sock, name)
|
||||||
|
debugmsg("service_dtcp(#{sock}, #{name})\n")
|
||||||
|
- while TRUE
|
||||||
|
+ while true
|
||||||
|
debugmsg("service_dtcp(#{sock}, #{name}) accepting\n")
|
||||||
|
Thread.start(sock.accept) { |s|
|
||||||
|
debugmsg("service_dtcp(#{sock}, #{name}) accepted #{s}\n")
|
||||||
|
@@ -912,7 +935,7 @@ def service_dtcp(sock, name)
|
||||||
|
|
||||||
|
# check response
|
||||||
|
# tunnel itojun RESPONSE type
|
||||||
|
- while TRUE
|
||||||
|
+ while true
|
||||||
|
t = IO.select([s], [], [s], tun == nil ? AUTHTIMEOUT : TUNTIMEOUT)
|
||||||
|
if t == nil
|
||||||
|
s.print "-ERR connection timed out, disconnecting\r\n"
|
||||||
|
@@ -1173,13 +1196,14 @@ port = 20200
|
||||||
$tunif = TUNIF
|
$tunif = TUNIF
|
||||||
$ng_tunif = "ng"
|
$ng_tunif = "ng"
|
||||||
$cloning = TUNIF_CLONING
|
$cloning = TUNIF_CLONING
|
||||||
|
@ -83,7 +113,7 @@ diff -u dtcps.rb.orig dtcps.rb
|
||||||
rescue
|
rescue
|
||||||
usage()
|
usage()
|
||||||
exit 0
|
exit 0
|
||||||
@@ -1190,6 +1214,7 @@
|
@@ -1190,6 +1214,7 @@ $udp_tunnel_port = params["b"].to_i if params["b"]
|
||||||
$cloning = false if params["c"]
|
$cloning = false if params["c"]
|
||||||
$debug = params["d"]
|
$debug = params["d"]
|
||||||
$daemonize = !params["D"]
|
$daemonize = !params["D"]
|
||||||
|
|
Loading…
Reference in a new issue