Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
f-interop-contributors
agent
Commits
aaf4b5df
Commit
aaf4b5df
authored
Jan 09, 2017
by
Federico Sismondi
Browse files
fixed logs, testing f-interop->tun interface
parent
2126cb34
Changes
1
Hide whitespace changes
Inline
Side-by-side
connectors/tun.py
View file @
aaf4b5df
...
...
@@ -13,8 +13,6 @@ from utils.opentun import OpenTunLinux, OpenTunMACOS
__version__
=
(
0
,
0
,
1
)
log
=
logging
.
getLogger
(
__name__
)
class
TunConsumer
(
BaseConsumer
):
"""
...
...
@@ -50,7 +48,7 @@ class TunConsumer(BaseConsumer):
- stop_tun
"""
loggin
g
.
info
(
'starting tun interface'
)
self
.
lo
g
.
info
(
'starting tun interface'
)
try
:
ipv6_host
=
msg
.
get
(
"ipv6_host"
,
None
)
ipv6_prefix
=
msg
.
get
(
"ipv6_prefix"
,
None
)
...
...
@@ -58,7 +56,7 @@ class TunConsumer(BaseConsumer):
ipv4_network
=
msg
.
get
(
"ipv4_network"
,
None
)
ipv4_netmask
=
msg
.
get
(
"ipv4_netmask"
,
None
)
except
AttributeError
as
ae
:
loggin
g
.
error
(
self
.
lo
g
.
error
(
'Wrong message format: {0}'
.
format
(
msg
.
payload
)
)
return
...
...
@@ -75,18 +73,18 @@ class TunConsumer(BaseConsumer):
}
if
sys
.
platform
.
startswith
(
'win32'
):
log
.
error
(
'Agent TunTap not yet supported for windows'
)
self
.
log
.
error
(
'Agent TunTap not yet supported for windows'
)
sys
.
exit
(
1
)
elif
sys
.
platform
.
startswith
(
'linux'
):
loggin
g
.
info
(
'Starting open tun [linux]'
)
self
.
lo
g
.
info
(
'Starting open tun [linux]'
)
self
.
tun
=
OpenTunLinux
(
**
params
)
elif
sys
.
platform
.
startswith
(
'darwin'
):
loggin
g
.
info
(
'Starting open tun [darwin]'
)
self
.
lo
g
.
info
(
'Starting open tun [darwin]'
)
self
.
tun
=
OpenTunMACOS
(
**
params
)
else
:
log
.
error
(
'Agent TunTap not yet supported for: {0}'
.
format
(
sys
.
platform
))
self
.
log
.
error
(
'Agent TunTap not yet supported for: {0}'
.
format
(
sys
.
platform
))
sys
.
exit
(
1
)
...
...
@@ -99,29 +97,39 @@ class TunConsumer(BaseConsumer):
Returns:
"""
self
.
log
.
debug
(
"HANDLE DATA
from tun
"
)
self
.
log
.
debug
(
"HANDLE DATA"
)
self
.
log
.
debug
((
"Payload"
,
message
.
payload
))
self
.
log
.
debug
((
"Properties"
,
message
.
properties
))
self
.
log
.
debug
((
"Headers"
,
message
.
headers
))
self
.
log
.
debug
((
"body"
,
message
.
body
))
#self.log.debug(("body", message.body))
self
.
log
.
debug
((
"Body"
,
body
))
self
.
log
.
debug
((
"type"
,
type
(
body
)))
assert
isinstance
(
body
,
dict
)
# body is already a dict, no need to json.load it
msg
=
body
if
msg
[
"_type"
]
==
'packet.raw'
:
#and not '.fromAgent' in message.delivery_info['routing_key']:
self
.
log
.
debug
(
"Message was routed, therefore we can inject it on our tun"
)
self
.
tun
.
_eventBusToTun
(
sender
=
"F-Interop server"
,
signal
=
"f-interop to agent"
,
data
=
msg
[
"data"
])
def
handle_control
(
self
,
body
,
message
):
msg
=
None
try
:
# body is a json
msg
=
json
.
loads
(
body
)
log
.
debug
(
message
)
self
.
log
.
debug
(
message
)
if
msg
[
"_type"
]:
log
.
debug
(
'HANDLE CONTROL from tun processing event type: {0}'
.
format
(
msg
[
"_type"
]))
self
.
log
.
debug
(
'HANDLE CONTROL from tun processing event type: {0}'
.
format
(
msg
[
"_type"
]))
except
(
ValueError
,
KeyError
)
as
e
:
message
.
ack
()
log
.
error
(
e
)
log
.
error
(
"Incorrect message: {0}"
.
format
(
message
.
payload
))
self
.
log
.
error
(
e
)
self
.
log
.
error
(
"Incorrect message: {0}"
.
format
(
message
.
payload
))
return
if
msg
[
"_type"
]
in
self
.
dispatcher
.
keys
():
self
.
dispatcher
[
msg
[
"_type"
]](
msg
)
else
:
log
.
debug
(
"Not supported action"
)
self
.
log
.
debug
(
"Not supported action"
)
# elif "data" in msg.keys():
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment