Skip to content

datatype: add DiameterURI Parse() method (RFC 6733 §4.3)#241

Merged
fiorix merged 2 commits into
fiorix:mainfrom
tridentsx:fix/237-diameteruri-parse
May 1, 2026
Merged

datatype: add DiameterURI Parse() method (RFC 6733 §4.3)#241
fiorix merged 2 commits into
fiorix:mainfrom
tridentsx:fix/237-diameteruri-parse

Conversation

@tridentsx

Copy link
Copy Markdown
Contributor

Add a Parse() method to DiameterURI that extracts scheme (aaa:// vs aaas://), FQDN, port, transport, and protocol per the RFC 6733 §4.3 ABNF.

Changes

  • Add ParsedDiameterURI struct with Secure, FQDN, Port, Transport, Protocol fields
  • Add Parse() method to DiameterURI type
  • Defaults: aaa:// → port 3868, aaas:// → port 5868, transport=tcp, protocol=diameter
  • Add 10 test cases (valid URIs + error cases)

RFC Reference

RFC 6733 §4.3 defines:

"aaa://" FQDN [ ":" port ] [ ";transport=" transport ] [ ";protocol=" protocol ]
"aaas://" FQDN [ ":" port ] [ ";transport=" transport ] [ ";protocol=" protocol ]

Backwards-compatible: the raw OctetString wire encoding is unchanged.

Fixes #237

Parse the aaa:// and aaas:// URI schemes extracting FQDN, port,
transport, and protocol parameters per the RFC 6733 §4.3 ABNF.

The aaas:// scheme indicates TLS-secured transport (default port 5868)
while aaa:// indicates unsecured (default port 3868).

Backwards-compatible: the raw OctetString wire encoding is unchanged.

Fixes fiorix#237
@fiorix

fiorix commented May 1, 2026

Copy link
Copy Markdown
Owner

Logic is right, a few things to address before merge:

  1. indexOf and lastIndexByte reimplement strings.Index / strings.LastIndexByte. Just import strings and drop the locals.
  2. RFC 6733 §4.3: "Diameter URIs are case insensitive." The scheme prefix match (raw[:7] == "aaas://") is case-sensitive. Use strings.EqualFold on the prefix, or lowercase before matching.
  3. Port parsing should use strconv.ParseUint(portStr, 10, 16) — the current loop silently wraps on values > 65535.
  4. Empty port (host:) currently parses as port 0; worth rejecting explicitly.

Happy either way: address here, or merge and follow up — your call.

- Replace custom indexOf/lastIndexByte with strings.Index/LastIndexByte
- Use strings.EqualFold for case-insensitive scheme matching (RFC 6733 §4.3)
- Use strconv.ParseUint(portStr, 10, 16) to reject ports > 65535
- Reject empty port ("host:") explicitly
- Add test cases for case-insensitive schemes, port overflow, empty port
@fiorix fiorix merged commit 9eb055c into fiorix:main May 1, 2026
1 check passed
tridentsx added a commit to tridentsx/go-diameter that referenced this pull request May 9, 2026
* datatype: add DiameterURI Parse() method (RFC 6733 §4.3)

Parse the aaa:// and aaas:// URI schemes extracting FQDN, port,
transport, and protocol parameters per the RFC 6733 §4.3 ABNF.

The aaas:// scheme indicates TLS-secured transport (default port 5868)
while aaa:// indicates unsecured (default port 3868).

Backwards-compatible: the raw OctetString wire encoding is unchanged.

Fixes fiorix#237

* datatype: address review comments on DiameterURI Parse

- Replace custom indexOf/lastIndexByte with strings.Index/LastIndexByte
- Use strings.EqualFold for case-insensitive scheme matching (RFC 6733 §4.3)
- Use strconv.ParseUint(portStr, 10, 16) to reject ports > 65535
- Reject empty port ("host:") explicitly
- Add test cases for case-insensitive schemes, port overflow, empty port
arberkatellari pushed a commit to arberkatellari/go-diameter that referenced this pull request May 12, 2026
* datatype: add DiameterURI Parse() method (RFC 6733 §4.3)

Parse the aaa:// and aaas:// URI schemes extracting FQDN, port,
transport, and protocol parameters per the RFC 6733 §4.3 ABNF.

The aaas:// scheme indicates TLS-secured transport (default port 5868)
while aaa:// indicates unsecured (default port 3868).

Backwards-compatible: the raw OctetString wire encoding is unchanged.

Fixes fiorix#237

* datatype: address review comments on DiameterURI Parse

- Replace custom indexOf/lastIndexByte with strings.Index/LastIndexByte
- Use strings.EqualFold for case-insensitive scheme matching (RFC 6733 §4.3)
- Use strconv.ParseUint(portStr, 10, 16) to reject ports > 65535
- Reject empty port ("host:") explicitly
- Add test cases for case-insensitive schemes, port overflow, empty port
danbogos pushed a commit to cgrates/go-diameter that referenced this pull request May 12, 2026
* datatype: add DiameterURI Parse() method (RFC 6733 §4.3)

Parse the aaa:// and aaas:// URI schemes extracting FQDN, port,
transport, and protocol parameters per the RFC 6733 §4.3 ABNF.

The aaas:// scheme indicates TLS-secured transport (default port 5868)
while aaa:// indicates unsecured (default port 3868).

Backwards-compatible: the raw OctetString wire encoding is unchanged.

Fixes fiorix#237

* datatype: address review comments on DiameterURI Parse

- Replace custom indexOf/lastIndexByte with strings.Index/LastIndexByte
- Use strings.EqualFold for case-insensitive scheme matching (RFC 6733 §4.3)
- Use strconv.ParseUint(portStr, 10, 16) to reject ports > 65535
- Reject empty port ("host:") explicitly
- Add test cases for case-insensitive schemes, port overflow, empty port
kulcsartibor pushed a commit to kulcsartibor/go-diameter that referenced this pull request Jun 10, 2026
* datatype: add DiameterURI Parse() method (RFC 6733 §4.3)

Parse the aaa:// and aaas:// URI schemes extracting FQDN, port,
transport, and protocol parameters per the RFC 6733 §4.3 ABNF.

The aaas:// scheme indicates TLS-secured transport (default port 5868)
while aaa:// indicates unsecured (default port 3868).

Backwards-compatible: the raw OctetString wire encoding is unchanged.

Fixes fiorix#237

* datatype: address review comments on DiameterURI Parse

- Replace custom indexOf/lastIndexByte with strings.Index/LastIndexByte
- Use strings.EqualFold for case-insensitive scheme matching (RFC 6733 §4.3)
- Use strconv.ParseUint(portStr, 10, 16) to reject ports > 65535
- Reject empty port ("host:") explicitly
- Add test cases for case-insensitive schemes, port overflow, empty port
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DiameterURI datatype is opaque — no parsing of aaa:// vs aaas:// scheme (RFC 6733 §4.3)

2 participants