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
6c37c796
Commit
6c37c796
authored
Nov 03, 2015
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
ac46a468
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
29 deletions
+37
-29
hacks.sh
hacks.sh
+5
-7
package.json
package.json
+2
-1
route.coffee
route.coffee
+30
-17
start.sh
start.sh
+0
-4
No files found.
hacks.sh
View file @
6c37c796
...
...
@@ -6,16 +6,14 @@ set -o allexport
source
/etc/railgun/profile
set
+o allexport
cd
`
dirname
$0
`
if
grep
-q
$1
hacks.csv
;
then
sed
-i
"s/
$1
.*/
$1
,
$2
/"
hacks.csv
if
grep
-q
$1
/etc/railgun/hacks.csv
;
then
sed
-i
"s/
$1
.*/
$1
,
$2
/"
/etc/railgun/hacks.csv
else
echo
$1
,
$2
>>
hacks.csv
echo
$1
,
$2
>>
/etc/railgun/
hacks.csv
fi
gateway
=
$(
awk
-F
,
"
\$
1 ==
$2
{ print
\$
2 }"
regions.csv
)
next_hop
=
$(
awk
-F
,
"
\$
1 ==
$2
{ print
\$
3 }"
regions.csv
)
gateway
=
$(
awk
-F
,
"
\$
1 ==
$2
{ print
\$
2 }"
/etc/railgun/
regions.csv
)
next_hop
=
$(
awk
-F
,
"
\$
1 ==
$2
{ print
\$
3 }"
/etc/railgun/
regions.csv
)
if
[
-z
"
${
gateway
}
"
]
||
[
-z
"
${
next_hop
}
"
]
;
then
echo
"can't find route for region
$2
"
exit
1
...
...
package.json
View file @
6c37c796
...
...
@@ -14,6 +14,7 @@
},
"homepage"
:
"
https://github.com/railgun-accelerator/railgun-network-client#readme
"
,
"dependencies"
:
{
"
pg
"
:
"
^4.4.3
"
"
pg
"
:
"
latest
"
,
"
csv
"
:
"
latest
"
}
}
route.coffee
View file @
6c37c796
fs
=
require
'fs'
child_process
=
require
'child_process'
csv
=
require
'csv'
ip_exec
=
(
commands
,
force
=
false
,
callback
)
->
args
=
[
'-batch'
,
'-'
]
...
...
@@ -17,6 +18,15 @@ iptables_exec = (commands, noflush = false, callback )->
child
.
on
'close'
,
callback
child
.
stdin
.
end
result
exec
=
(
ipforce
,
ip
,
iptables
)
->
ip_exec
ipforce
,
true
,
(
code
)
->
console
.
log
code
ip_exec
ip
,
false
,
(
code
)
->
console
.
log
code
iptables_exec
iptables
,
true
,
(
code
)
->
console
.
log
code
process
.
exit
()
module
.
exports
=
init
:
(
server_id
,
servers
,
regions
)
->
...
...
@@ -105,20 +115,23 @@ module.exports =
else
ip
.
push
"route add
#{
address
}
advmss 1360 dev railgun
#{
servers
[
region
.
gateway
].
next_hop
}
src
#{
servers
[
server_id
].
host
}
realm
#{
region
.
gateway
}
table 101"
#console.log ipforce.join("\n")
#console.log '-'
ip_exec
ipforce
,
true
,
(
code
)
->
console
.
log
code
#console.log error, stdout, stderr
#console.log ip.join("\n")
ip_exec
ip
,
false
,
(
code
)
->
#throw error if error
console
.
log
code
iptables_exec
iptables
,
true
,
(
code
)
->
console
.
log
code
#throw error if error
# 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
i
,
region
of
regions
when
region
.
gateway
?
).
join
(
"
\n
"
),
(
error
)
->
throw
error
if
error
process
.
exit
()
# hacks
csv
.
stringify
([
region
.
id
,
region
.
gateway
,
servers
[
region
.
gateway
].
next_hop
]
for
i
,
region
of
regions
when
region
.
gateway
?
),
(
error
,
data
)
->
throw
error
if
error
fs
.
writeFile
'/etc/railgun/regions.csv'
,
(
error
)
->
throw
error
if
error
fs
.
readFile
'/etc/railgun/hacks.csv'
,
(
error
,
data
)
->
if
data
csv
.
parse
data
,
(
error
,
data
)
->
if
data
for
hack
in
data
[
address
,
region_id
]
=
hack
region
=
regions
[
region_id
]
if
region
and
region
.
gateway
?
if
region
.
gateway
==
server_id
ip
.
push
"route replace
#{
address
}
via
#{
process
.
env
.
RAILGUN_GATEWAY
}
table 101"
else
ip
.
push
"route add
#{
address
}
advmss 1360 dev railgun
#{
servers
[
region
.
gateway
].
next_hop
}
src
#{
servers
[
server_id
].
host
}
realm
#{
region
.
gateway
}
table 101"
exec
(
ipforce
,
ip
,
iptables
)
else
exec
(
ipforce
,
ip
,
iptables
)
start.sh
View file @
6c37c796
...
...
@@ -12,10 +12,6 @@ ipset create -exist ports1 bitmap:port range 10000-32767
ipset create
-exist
ports2 bitmap:port range 10000-32767
ipset create
-exist
ports3 bitmap:port range 10000-32767
ipset create
-exist
block_ip
hash
:ip
ipset create
-exist
region1
hash
:net
ipset create
-exist
region2
hash
:net
ipset create
-exist
region3
hash
:net
ipset create
-exist
region4
hash
:net
echo
'iptables...'
...
...
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