Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ext-respondd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
infrastruktur
ext-respondd
Commits
1dea7ed0
Commit
1dea7ed0
authored
Jun 20, 2017
by
Marcus Scharf
Browse files
Options
Downloads
Patches
Plain Diff
style rework / fix bug in traffic and memory / no alias.json needed
parent
63adccf6
No related branches found
No related tags found
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
lib/helper.py
+4
-3
4 additions, 3 deletions
lib/helper.py
lib/nodeinfo.py
+6
-3
6 additions, 3 deletions
lib/nodeinfo.py
lib/ratelimit.py
+2
-0
2 additions, 0 deletions
lib/ratelimit.py
lib/respondd.py
+4
-3
4 additions, 3 deletions
lib/respondd.py
lib/statistics.py
+2
-2
2 additions, 2 deletions
lib/statistics.py
with
18 additions
and
11 deletions
lib/helper.py
+
4
−
3
View file @
1dea7ed0
...
@@ -9,12 +9,13 @@ def call(cmdnargs):
...
@@ -9,12 +9,13 @@ def call(cmdnargs):
output
=
subprocess
.
check_output
(
cmdnargs
,
stderr
=
subprocess
.
STDOUT
)
output
=
subprocess
.
check_output
(
cmdnargs
,
stderr
=
subprocess
.
STDOUT
)
lines
=
output
.
splitlines
()
lines
=
output
.
splitlines
()
lines
=
[
line
.
decode
(
'
utf-8
'
)
for
line
in
lines
]
lines
=
[
line
.
decode
(
'
utf-8
'
)
for
line
in
lines
]
return
lines
except
subprocess
.
CalledProcessError
as
err
:
except
subprocess
.
CalledProcessError
as
err
:
print
(
err
)
print
(
err
)
return
[]
except
:
except
:
print
(
str
(
sys
.
exc_info
()[
0
]))
print
(
str
(
sys
.
exc_info
()[
0
]))
else
:
return
lines
return
[]
return
[]
def
merge
(
a
,
b
):
def
merge
(
a
,
b
):
...
...
This diff is collapsed.
Click to expand it.
lib/nodeinfo.py
+
6
−
3
View file @
1dea7ed0
...
@@ -73,7 +73,7 @@ class Nodeinfo(Respondd):
...
@@ -73,7 +73,7 @@ class Nodeinfo(Respondd):
return
ret
return
ret
@staticmethod
@staticmethod
def
getVPN
(
batmanInterface
):
def
getVPN
Flag
(
batmanInterface
):
lines
=
lib
.
helper
.
call
([
'
batctl
'
,
'
-m
'
,
batmanInterface
,
'
gw_mode
'
])
lines
=
lib
.
helper
.
call
([
'
batctl
'
,
'
-m
'
,
batmanInterface
,
'
gw_mode
'
])
if
re
.
match
(
r
'
^server
'
,
lines
[
0
]):
if
re
.
match
(
r
'
^server
'
,
lines
[
0
]):
return
True
return
True
...
@@ -115,7 +115,7 @@ class Nodeinfo(Respondd):
...
@@ -115,7 +115,7 @@ class Nodeinfo(Respondd):
'
owner
'
:
{},
'
owner
'
:
{},
'
system
'
:
{},
'
system
'
:
{},
'
location
'
:
{},
'
location
'
:
{},
'
vpn
'
:
self
.
getVPN
(
self
.
_config
[
'
batman
'
])
'
vpn
'
:
self
.
getVPN
Flag
(
self
.
_config
[
'
batman
'
])
}
}
if
'
mesh-vpn
'
in
self
.
_config
and
len
(
self
.
_config
[
'
mesh-vpn
'
])
>
0
:
if
'
mesh-vpn
'
in
self
.
_config
and
len
(
self
.
_config
[
'
mesh-vpn
'
])
>
0
:
...
@@ -127,5 +127,8 @@ class Nodeinfo(Respondd):
...
@@ -127,5 +127,8 @@ class Nodeinfo(Respondd):
except
:
except
:
pass
pass
if
'
nodeinfo
'
in
self
.
_aliasOverlay
:
return
lib
.
helper
.
merge
(
ret
,
self
.
_aliasOverlay
[
'
nodeinfo
'
])
return
lib
.
helper
.
merge
(
ret
,
self
.
_aliasOverlay
[
'
nodeinfo
'
])
else
:
return
ret
This diff is collapsed.
Click to expand it.
lib/ratelimit.py
+
2
−
0
View file @
1dea7ed0
#!/usr/bin/env python3
#!/usr/bin/env python3
import
time
class
rateLimit
:
# rate limit like iptables limit (per minutes)
class
rateLimit
:
# rate limit like iptables limit (per minutes)
tLast
=
None
tLast
=
None
...
...
This diff is collapsed.
Click to expand it.
lib/respondd.py
+
4
−
3
View file @
1dea7ed0
...
@@ -10,13 +10,14 @@ class Respondd:
...
@@ -10,13 +10,14 @@ class Respondd:
self
.
_config
=
config
self
.
_config
=
config
self
.
_aliasOverlay
=
{}
self
.
_aliasOverlay
=
{}
try
:
try
:
with
open
(
'
alias.json
'
,
'
r
'
)
as
fh
:
with
open
(
'
alias.json
'
,
'
r
'
)
as
fh
:
# TODO: prevent loading more then once !
self
.
_aliasOverlay
=
json
.
load
(
fh
)
self
.
_aliasOverlay
=
json
.
load
(
fh
)
except
IOError
:
except
IOError
:
raise
print
(
'
can
\'
t load alias.json!
'
)
pass
def
getNodeID
(
self
):
def
getNodeID
(
self
):
if
'
node_id
'
in
self
.
_aliasOverlay
[
'
nodeinfo
'
]:
if
'
nodeinfo
'
in
self
.
_aliasOverlay
and
'
node_id
'
in
self
.
_aliasOverlay
[
'
nodeinfo
'
]:
return
self
.
_aliasOverlay
[
'
nodeinfo
'
][
'
node_id
'
]
return
self
.
_aliasOverlay
[
'
nodeinfo
'
][
'
node_id
'
]
else
:
else
:
return
lib
.
helper
.
getInterfaceMAC
(
self
.
_config
[
'
batman
'
]).
replace
(
'
:
'
,
''
)
return
lib
.
helper
.
getInterfaceMAC
(
self
.
_config
[
'
batman
'
]).
replace
(
'
:
'
,
''
)
...
...
This diff is collapsed.
Click to expand it.
lib/statistics.py
+
2
−
2
View file @
1dea7ed0
...
@@ -51,7 +51,7 @@ class Statistics(Respondd):
...
@@ -51,7 +51,7 @@ class Statistics(Respondd):
lineSplit
=
line
.
strip
().
split
(
'
:
'
,
1
)
lineSplit
=
line
.
strip
().
split
(
'
:
'
,
1
)
name
=
lineSplit
[
0
]
name
=
lineSplit
[
0
]
value
=
lineSplit
[
1
].
strip
()
value
=
lineSplit
[
1
].
strip
()
traffic
[
name
]
=
value
traffic
[
name
]
=
int
(
value
)
ret
=
{
ret
=
{
'
tx
'
:
{
'
tx
'
:
{
...
@@ -86,7 +86,7 @@ class Statistics(Respondd):
...
@@ -86,7 +86,7 @@ class Statistics(Respondd):
for
line
in
lines
:
for
line
in
lines
:
lineSplit
=
line
.
split
(
'
'
,
1
)
lineSplit
=
line
.
split
(
'
'
,
1
)
name
=
lineSplit
[
0
][:
-
1
]
name
=
lineSplit
[
0
][:
-
1
]
value
=
lineSplit
[
1
].
strip
().
split
(
'
'
,
1
)[
0
]
value
=
int
(
lineSplit
[
1
].
strip
().
split
(
'
'
,
1
)[
0
]
)
if
name
==
'
MemTotal
'
:
if
name
==
'
MemTotal
'
:
ret
[
'
total
'
]
=
value
ret
[
'
total
'
]
=
value
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment