Skip to content

Commit

Permalink
add support for validator dns protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
minaxolone committed Apr 30, 2024
1 parent 94f1c0a commit 9b91c8a
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions api/src/ol/network-addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ class Ip6Protocol implements INetworkProtocol {
}
}

class DnsProtocol implements INetworkProtocol {
public constructor(public readonly name: string) {
}

public toString(): string {
return `/dns/${this.name}`;
}
}

class TcpProtocol implements INetworkProtocol {
public constructor(public readonly port: number) {
if (port < 0 || port > 0xFFFF) {
Expand Down Expand Up @@ -76,7 +85,8 @@ type NetworkProtocol =
| Ip6Protocol
| TcpProtocol
| NoiseIKProtocol
| HandshakeProtocol;
| HandshakeProtocol
| DnsProtocol;

type ProtocolDeserializer = (deserializer: BCS.Deserializer) => NetworkProtocol;

Expand Down Expand Up @@ -105,23 +115,24 @@ export class NetworkAddresses {
},

function dns(deserializer: BCS.Deserializer) {
throw new Error('unimplemented');
const name = deserializer.deserializeStr();
return new DnsProtocol(name);
},

function dns4(deserializer: BCS.Deserializer) {
throw new Error('unimplemented');
throw new Error('dns4 unimplemented');
},

function dns6(deserializer: BCS.Deserializer) {
throw new Error('unimplemented');
throw new Error('dns6 unimplemented');
},

function tcp(deserializer: BCS.Deserializer) {
return new TcpProtocol(deserializer.deserializeU16());
},

function memory(deserializer: BCS.Deserializer) {
throw new Error('unimplemented');
throw new Error('memory unimplemented');
},

function noiseIK(deserializer: BCS.Deserializer) {
Expand Down

0 comments on commit 9b91c8a

Please sign in to comment.