-
Notifications
You must be signed in to change notification settings - Fork 298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Table app args refactoring #293
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4945331
[core.config] Make `parse_app_arg' a NOOP for tables.
eugeneia edda471
[META] Use `core.config.parse_app_arg' uniformly.
eugeneia 40b6518
[META] Refrain from using `([[{...}]]):format(...)' constructs
eugeneia 6514ce3
[core.config] Remove type checking of `arg' in `config.app()'.
eugeneia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,8 +102,8 @@ end | |
|
||
SimpleKeyedTunnel = {} | ||
|
||
function SimpleKeyedTunnel:new (confstring) | ||
local config = confstring and loadstring("return " .. confstring)() or {} | ||
function SimpleKeyedTunnel:new (arg) | ||
local conf = arg and config.parse_app_arg(arg) or {} | ||
-- required fields: | ||
-- local_address, string, ipv6 address | ||
-- remote_address, string, ipv6 address | ||
|
@@ -114,23 +114,22 @@ function SimpleKeyedTunnel:new (confstring) | |
-- default_gateway_MAC, useful for testing | ||
-- hop_limit, override default hop limit 64 | ||
assert( | ||
type(config.local_cookie) == "string" | ||
and #config.local_cookie <= 16, | ||
type(conf.local_cookie) == "string" | ||
and #conf.local_cookie <= 16, | ||
"local_cookie should be 8 bytes hex string" | ||
) | ||
config.local_cookie = lib.hexundump(config.local_cookie, 8) | ||
assert( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I went over this I realized how bad this is (destructively modifying the |
||
type(config.remote_cookie) == "string" | ||
and #config.remote_cookie <= 16, | ||
type(conf.remote_cookie) == "string" | ||
and #conf.remote_cookie <= 16, | ||
"remote_cookie should be 8 bytes hex string" | ||
) | ||
config.remote_cookie = lib.hexundump(config.remote_cookie, 8) | ||
local header = header_array_ctype(HEADER_SIZE) | ||
ffi.copy(header, header_template, HEADER_SIZE) | ||
local local_cookie = lib.hexundump(conf.local_cookie, 8) | ||
ffi.copy( | ||
header + COOKIE_OFFSET, | ||
config.local_cookie, | ||
#config.local_cookie | ||
local_cookie, | ||
#local_cookie | ||
) | ||
|
||
-- convert dest, sorce ipv6 addressed to network order binary | ||
|
@@ -146,22 +145,22 @@ function SimpleKeyedTunnel:new (confstring) | |
local remote_address = ffi.cast(paddress_ctype, header + DST_IP_OFFSET) | ||
local local_address = ffi.cast(paddress_ctype, header + SRC_IP_OFFSET) | ||
|
||
local remote_cookie = ffi.cast(pcookie_ctype, config.remote_cookie) | ||
local remote_cookie = ffi.cast(pcookie_ctype, lib.hexundump(conf.remote_cookie, 8)) | ||
|
||
if config.local_session then | ||
if conf.local_session then | ||
local psession = ffi.cast(psession_id_ctype, header + SESSION_ID_OFFSET) | ||
psession[0] = lib.htonl(config.local_session) | ||
psession[0] = lib.htonl(conf.local_session) | ||
end | ||
|
||
if config.default_gateway_MAC then | ||
local mac = assert(macaddress:new(config.default_gateway_MAC)) | ||
if conf.default_gateway_MAC then | ||
local mac = assert(macaddress:new(conf.default_gateway_MAC)) | ||
ffi.copy(header + DST_MAC_OFFSET, mac.bytes, 6) | ||
end | ||
|
||
if config.hop_limit then | ||
assert(type(config.hop_limit) == 'number' and | ||
config.hop_limit <= 255, "invalid hop limit") | ||
header[HOP_LIMIT_OFFSET] = config.hop_limit | ||
if conf.hop_limit then | ||
assert(type(conf.hop_limit) == 'number' and | ||
conf.hop_limit <= 255, "invalid hop limit") | ||
header[HOP_LIMIT_OFFSET] = conf.hop_limit | ||
end | ||
|
||
local o = | ||
|
@@ -274,15 +273,13 @@ function selftest () | |
|
||
local input_file = "apps/keyed_ipv6_tunnel/selftest.cap.input" | ||
local output_file = "apps/keyed_ipv6_tunnel/selftest.cap.output" | ||
local tunnel_config = | ||
[[{ | ||
local tunnel_config = { | ||
local_address = "00::2:1", | ||
remote_address = "00::2:1", | ||
local_cookie = "12345678", | ||
remote_cookie = "12345678", | ||
default_gateway_MAC = "a1:b2:c3:d4:e5:f6" | ||
} | ||
]] -- should be symmetric for local "loop-back" test | ||
} -- should be symmetric for local "loop-back" test | ||
|
||
buffer.preallocate(10000) | ||
local c = config.new() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prepend
local
.