Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
R
railgun-routing-client
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Railgun
railgun-routing-client
Commits
0562d33c
Commit
0562d33c
authored
Nov 03, 2015
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hacks
parent
c8a1da15
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
1 deletion
+27
-1
hacks.sh
hacks.sh
+21
-0
route.coffee
route.coffee
+6
-1
No files found.
hacks.sh
0 → 100755
View file @
0562d33c
#!/usr/bin/env bash
set
-o
errexit
if
grep
-q
$1
hacks.csv
;
then
sed
-i
"s/
$1
.*/
$1
,
$2
/"
hacks.csv
else
echo
$1
,
$2
>>
hacks.csv
fi
gateway
=
$(
awk
-F
,
"
\$
1 ==
$2
{ print
\$
2 }"
regions.csv
)
next_hop
=
$(
awk
-F
,
"
\$
1 ==
$2
{ print
\$
3 }"
regions.csv
)
if
[
-z
"
${
gateway
}
"
]
||
[
-z
"
${
next_hop
}
"
]
;
then
echo
"can't find route for region
$2
"
exit
1
fi
if
[
"
${
gateway
}
"
=
"
${
RAILGUN_ID
}
"
]
;
then
echo
ip route add
$1
via
${
RAILGUN_GATEWAY
}
else
echo
ip route add
$1
dev railgun
${
next_hop
}
src
${
RAILGUN_ADDRESS
}
realm
${
gateway
}
advmss 1360
fi
\ No newline at end of file
route.coffee
View file @
0562d33c
fs
=
require
'fs'
child_process
=
require
'child_process'
ip_exec
=
(
commands
,
force
=
false
,
callback
)
->
...
...
@@ -116,4 +117,8 @@ module.exports =
iptables_exec
iptables
,
true
,
(
code
)
->
console
.
log
code
#throw error if error
process
.
exit
()
# save route to file, for hacks
# fs.writeFile 'servers.csv', ([server.id, server.next_hop].join(',') for server in servers when server.next_hop?).join("\n") # we don't need it now.
fs
.
writeFile
'regions.csv'
,
([
region
.
id
,
region
.
gateway
,
servers
[
region
.
gateway
].
next_hop
].
join
(
','
)
for
region
in
regions
when
region
.
gateway
?
).
join
(
"
\n
"
),
(
error
)
->
throw
error
if
error
process
.
exit
()
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