Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Dunitrust
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
nodes
rust
Dunitrust
Commits
6fed3aab
Commit
6fed3aab
authored
5 years ago
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
[fix] network-docs: parse endpoint v1 with ip
parent
22599cb4
No related branches found
No related tags found
1 merge request
!217
Elois/fix
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/dunp/network-documents/src/network_documents.pest
+3
-2
3 additions, 2 deletions
lib/dunp/network-documents/src/network_documents.pest
lib/dunp/network-documents/src/network_endpoint.rs
+35
-1
35 additions, 1 deletion
lib/dunp/network-documents/src/network_endpoint.rs
with
38 additions
and
3 deletions
lib/dunp/network-documents/src/network_documents.pest
+
3
−
2
View file @
6fed3aab
...
@@ -25,11 +25,12 @@ ed25519_sig = @{ base64{88} | (base64{87} ~ "=") | (base64{86} ~ "==") }
...
@@ -25,11 +25,12 @@ ed25519_sig = @{ base64{88} | (base64{87} ~ "=") | (base64{86} ~ "==") }
// Endpoint v1 rules
// Endpoint v1 rules
api_name = @{ (ASCII_ALPHA_UPPER | ASCII_DIGIT | "_")+ }
api_name = @{ (ASCII_ALPHA_UPPER | ASCII_DIGIT | "_")+ }
node_id = @{ hexa_lower{1,8} }
node_id = @{ hexa_lower{1,8} }
host = @{ ASCII_ALPHA_LOWER ~ (alphanum_lower | "-" | "_" | ".")* }
host = _{ host_inner ~ " " }
host_inner = @{ ASCII_ALPHA_LOWER ~ (alphanum_lower | "-" | "_" | ".")* }
port = @{ u_int }
port = @{ u_int }
path_inner = @{ (ASCII_ALPHANUMERIC | "-" | "_" | ".")+ }
path_inner = @{ (ASCII_ALPHANUMERIC | "-" | "_" | ".")+ }
endpoint_v1 = ${ api_name ~ (" " ~ node_id)? ~ " " ~ (ip4 | ip6 | host) ~
" " ~
port ~ (" " ~ "/"? ~ path_inner)? ~ " "? }
endpoint_v1 = ${ api_name ~ (" " ~ node_id)? ~ " " ~ (ip4 | ip6 | host) ~ port ~ (" " ~ "/"? ~ path_inner)? ~ " "? }
// IP v6 rules
// IP v6 rules
ip6_seg = _{ hexa_lower{1,4} }
ip6_seg = _{ hexa_lower{1,4} }
...
...
This diff is collapsed.
Click to expand it.
lib/dunp/network-documents/src/network_endpoint.rs
+
35
−
1
View file @
6fed3aab
...
@@ -175,7 +175,9 @@ impl EndpointV1 {
...
@@ -175,7 +175,9 @@ impl EndpointV1 {
None
=>
None
,
None
=>
None
,
};
};
}
}
Rule
::
host
=>
host_str
=
ep_pair
.as_str
(),
Rule
::
host_inner
=>
host_str
=
ep_pair
.as_str
(),
Rule
::
ip4_inner
=>
host_str
=
ep_pair
.as_str
(),
Rule
::
ip6_inner
=>
host_str
=
ep_pair
.as_str
(),
Rule
::
port
=>
port
=
ep_pair
.as_str
()
.parse
()
.unwrap
(),
Rule
::
port
=>
port
=
ep_pair
.as_str
()
.parse
()
.unwrap
(),
Rule
::
path_inner
=>
path
=
Some
(
String
::
from
(
ep_pair
.as_str
())),
Rule
::
path_inner
=>
path
=
Some
(
String
::
from
(
ep_pair
.as_str
())),
_
=>
fatal_error!
(
"unexpected rule: {:?}"
,
ep_pair
.as_rule
()),
// Grammar ensures that we never reach this line
_
=>
fatal_error!
(
"unexpected rule: {:?}"
,
ep_pair
.as_rule
()),
// Grammar ensures that we never reach this line
...
@@ -561,6 +563,38 @@ mod tests {
...
@@ -561,6 +563,38 @@ mod tests {
use
super
::
*
;
use
super
::
*
;
use
bincode
::{
deserialize
,
serialize
};
use
bincode
::{
deserialize
,
serialize
};
use
maplit
::
hashset
;
use
maplit
::
hashset
;
use
unwrap
::
unwrap
;
#[test]
fn
test_parse_endpoint_v1_with_ip
()
->
Result
<
(),
TextDocumentParseError
>
{
let
issuer
=
PubKey
::
Ed25519
(
unwrap!
(
ed25519
::
PublicKey
::
from_base58
(
"8iVdpXqFLCxGyPqgVx5YbFSkmWKkceXveRd2yvBKeARL"
,
)));
let
parser_ep_v1
=
EndpointV1
::
parse_from_raw
(
"WS2P e66254bf 91.121.157.13 20901"
,
issuer
,
0
,
0
)
?
;
assert_eq!
(
EndpointV1
{
api
:
ApiName
(
String
::
from
(
"WS2P"
)),
node_id
:
Some
(
NodeId
::
from
(
"e66254bf"
)),
issuer
,
hash_full_id
:
Some
(
Hash
::
from_hex
(
"B56286E3A423B1BD4A116F0358795870A4136C97CEE955F144C84C6EE27B8BFB"
)
.expect
(
"wrong hard hash"
)
),
host
:
String
::
from
(
"91.121.157.13"
),
port
:
20901
,
path
:
None
,
raw_endpoint
:
String
::
from
(
"WS2P e66254bf 91.121.157.13 20901"
),
status
:
0
,
last_check
:
0
,
},
parser_ep_v1
);
Ok
(())
}
#[inline]
#[inline]
fn
api_part_1
()
->
ApiPart
{
fn
api_part_1
()
->
ApiPart
{
...
...
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