fix missing address range for local

This commit is contained in:
Christien Rioux 2024-02-16 09:19:26 -07:00
parent 34a861aa69
commit 2156449486
4 changed files with 349 additions and 27 deletions

View File

@ -50,6 +50,7 @@ impl Address {
Address::IPV4(v4) => {
ipv4addr_is_private(v4)
|| ipv4addr_is_link_local(v4)
|| ipv4addr_is_shared(v4)
|| ipv4addr_is_ietf_protocol_assignment(v4)
}
Address::IPV6(v6) => {

View File

@ -175,14 +175,8 @@ sealed class VeilidUpdate with _$VeilidUpdate {
required ValueData valueData,
}) = VeilidUpdateValueChange;
factory VeilidUpdate.fromJson(dynamic json) {
try {
return _$VeilidUpdateFromJson(json as Map<String, dynamic>);
} catch (e) {
print('VeilidUpdateFromJson failed: $e');
rethrow;
}
}
factory VeilidUpdate.fromJson(dynamic json) =>
_$VeilidUpdateFromJson(json as Map<String, dynamic>);
}
//////////////////////////////////////

View File

@ -1306,6 +1306,31 @@ abstract class _PeerTableData implements PeerTableData {
throw _privateConstructorUsedError;
}
VeilidUpdate _$VeilidUpdateFromJson(Map<String, dynamic> json) {
switch (json['kind']) {
case 'Log':
return VeilidLog.fromJson(json);
case 'AppMessage':
return VeilidAppMessage.fromJson(json);
case 'AppCall':
return VeilidAppCall.fromJson(json);
case 'Attachment':
return VeilidUpdateAttachment.fromJson(json);
case 'Network':
return VeilidUpdateNetwork.fromJson(json);
case 'Config':
return VeilidUpdateConfig.fromJson(json);
case 'RouteChange':
return VeilidUpdateRouteChange.fromJson(json);
case 'ValueChange':
return VeilidUpdateValueChange.fromJson(json);
default:
throw CheckedFromJsonException(json, 'kind', 'VeilidUpdate',
'Invalid union type "${json['kind']}"!');
}
}
/// @nodoc
mixin _$VeilidUpdate {
@optionalTypeArgs
@ -1422,6 +1447,7 @@ mixin _$VeilidUpdate {
required TResult orElse(),
}) =>
throw _privateConstructorUsedError;
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
}
/// @nodoc
@ -1484,10 +1510,17 @@ class __$$VeilidLogImplCopyWithImpl<$Res>
}
/// @nodoc
@JsonSerializable()
class _$VeilidLogImpl implements VeilidLog {
const _$VeilidLogImpl(
{required this.logLevel, required this.message, this.backtrace});
{required this.logLevel,
required this.message,
this.backtrace,
final String? $type})
: $type = $type ?? 'Log';
factory _$VeilidLogImpl.fromJson(Map<String, dynamic> json) =>
_$$VeilidLogImplFromJson(json);
@override
final VeilidLogLevel logLevel;
@ -1496,6 +1529,9 @@ class _$VeilidLogImpl implements VeilidLog {
@override
final String? backtrace;
@JsonKey(name: 'kind')
final String $type;
@override
String toString() {
return 'VeilidUpdate.log(logLevel: $logLevel, message: $message, backtrace: $backtrace)';
@ -1513,6 +1549,7 @@ class _$VeilidLogImpl implements VeilidLog {
other.backtrace == backtrace));
}
@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(runtimeType, logLevel, message, backtrace);
@ -1659,6 +1696,13 @@ class _$VeilidLogImpl implements VeilidLog {
}
return orElse();
}
@override
Map<String, dynamic> toJson() {
return _$$VeilidLogImplToJson(
this,
);
}
}
abstract class VeilidLog implements VeilidUpdate {
@ -1667,6 +1711,9 @@ abstract class VeilidLog implements VeilidUpdate {
required final String message,
final String? backtrace}) = _$VeilidLogImpl;
factory VeilidLog.fromJson(Map<String, dynamic> json) =
_$VeilidLogImpl.fromJson;
VeilidLogLevel get logLevel;
String get message;
String? get backtrace;
@ -1714,10 +1761,16 @@ class __$$VeilidAppMessageImplCopyWithImpl<$Res>
}
/// @nodoc
@JsonSerializable()
class _$VeilidAppMessageImpl implements VeilidAppMessage {
const _$VeilidAppMessageImpl(
{@Uint8ListJsonConverter() required this.message, this.sender});
{@Uint8ListJsonConverter() required this.message,
this.sender,
final String? $type})
: $type = $type ?? 'AppMessage';
factory _$VeilidAppMessageImpl.fromJson(Map<String, dynamic> json) =>
_$$VeilidAppMessageImplFromJson(json);
@override
@Uint8ListJsonConverter()
@ -1725,6 +1778,9 @@ class _$VeilidAppMessageImpl implements VeilidAppMessage {
@override
final Typed<FixedEncodedString43>? sender;
@JsonKey(name: 'kind')
final String $type;
@override
String toString() {
return 'VeilidUpdate.appMessage(message: $message, sender: $sender)';
@ -1739,6 +1795,7 @@ class _$VeilidAppMessageImpl implements VeilidAppMessage {
(identical(other.sender, sender) || other.sender == sender));
}
@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(
runtimeType, const DeepCollectionEquality().hash(message), sender);
@ -1887,6 +1944,13 @@ class _$VeilidAppMessageImpl implements VeilidAppMessage {
}
return orElse();
}
@override
Map<String, dynamic> toJson() {
return _$$VeilidAppMessageImplToJson(
this,
);
}
}
abstract class VeilidAppMessage implements VeilidUpdate {
@ -1894,6 +1958,9 @@ abstract class VeilidAppMessage implements VeilidUpdate {
{@Uint8ListJsonConverter() required final Uint8List message,
final Typed<FixedEncodedString43>? sender}) = _$VeilidAppMessageImpl;
factory VeilidAppMessage.fromJson(Map<String, dynamic> json) =
_$VeilidAppMessageImpl.fromJson;
@Uint8ListJsonConverter()
Uint8List get message;
Typed<FixedEncodedString43>? get sender;
@ -1947,12 +2014,17 @@ class __$$VeilidAppCallImplCopyWithImpl<$Res>
}
/// @nodoc
@JsonSerializable()
class _$VeilidAppCallImpl implements VeilidAppCall {
const _$VeilidAppCallImpl(
{@Uint8ListJsonConverter() required this.message,
required this.callId,
this.sender});
this.sender,
final String? $type})
: $type = $type ?? 'AppCall';
factory _$VeilidAppCallImpl.fromJson(Map<String, dynamic> json) =>
_$$VeilidAppCallImplFromJson(json);
@override
@Uint8ListJsonConverter()
@ -1962,6 +2034,9 @@ class _$VeilidAppCallImpl implements VeilidAppCall {
@override
final Typed<FixedEncodedString43>? sender;
@JsonKey(name: 'kind')
final String $type;
@override
String toString() {
return 'VeilidUpdate.appCall(message: $message, callId: $callId, sender: $sender)';
@ -1977,6 +2052,7 @@ class _$VeilidAppCallImpl implements VeilidAppCall {
(identical(other.sender, sender) || other.sender == sender));
}
@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(runtimeType,
const DeepCollectionEquality().hash(message), callId, sender);
@ -2124,6 +2200,13 @@ class _$VeilidAppCallImpl implements VeilidAppCall {
}
return orElse();
}
@override
Map<String, dynamic> toJson() {
return _$$VeilidAppCallImplToJson(
this,
);
}
}
abstract class VeilidAppCall implements VeilidUpdate {
@ -2132,6 +2215,9 @@ abstract class VeilidAppCall implements VeilidUpdate {
required final String callId,
final Typed<FixedEncodedString43>? sender}) = _$VeilidAppCallImpl;
factory VeilidAppCall.fromJson(Map<String, dynamic> json) =
_$VeilidAppCallImpl.fromJson;
@Uint8ListJsonConverter()
Uint8List get message;
String get callId;
@ -2188,12 +2274,17 @@ class __$$VeilidUpdateAttachmentImplCopyWithImpl<$Res>
}
/// @nodoc
@JsonSerializable()
class _$VeilidUpdateAttachmentImpl implements VeilidUpdateAttachment {
const _$VeilidUpdateAttachmentImpl(
{required this.state,
required this.publicInternetReady,
required this.localNetworkReady});
required this.localNetworkReady,
final String? $type})
: $type = $type ?? 'Attachment';
factory _$VeilidUpdateAttachmentImpl.fromJson(Map<String, dynamic> json) =>
_$$VeilidUpdateAttachmentImplFromJson(json);
@override
final AttachmentState state;
@ -2202,6 +2293,9 @@ class _$VeilidUpdateAttachmentImpl implements VeilidUpdateAttachment {
@override
final bool localNetworkReady;
@JsonKey(name: 'kind')
final String $type;
@override
String toString() {
return 'VeilidUpdate.attachment(state: $state, publicInternetReady: $publicInternetReady, localNetworkReady: $localNetworkReady)';
@ -2219,6 +2313,7 @@ class _$VeilidUpdateAttachmentImpl implements VeilidUpdateAttachment {
other.localNetworkReady == localNetworkReady));
}
@JsonKey(ignore: true)
@override
int get hashCode =>
Object.hash(runtimeType, state, publicInternetReady, localNetworkReady);
@ -2367,6 +2462,13 @@ class _$VeilidUpdateAttachmentImpl implements VeilidUpdateAttachment {
}
return orElse();
}
@override
Map<String, dynamic> toJson() {
return _$$VeilidUpdateAttachmentImplToJson(
this,
);
}
}
abstract class VeilidUpdateAttachment implements VeilidUpdate {
@ -2375,6 +2477,9 @@ abstract class VeilidUpdateAttachment implements VeilidUpdate {
required final bool publicInternetReady,
required final bool localNetworkReady}) = _$VeilidUpdateAttachmentImpl;
factory VeilidUpdateAttachment.fromJson(Map<String, dynamic> json) =
_$VeilidUpdateAttachmentImpl.fromJson;
AttachmentState get state;
bool get publicInternetReady;
bool get localNetworkReady;
@ -2431,14 +2536,19 @@ class __$$VeilidUpdateNetworkImplCopyWithImpl<$Res>
}
/// @nodoc
@JsonSerializable()
class _$VeilidUpdateNetworkImpl implements VeilidUpdateNetwork {
const _$VeilidUpdateNetworkImpl(
{required this.started,
required this.bpsDown,
required this.bpsUp,
required final List<PeerTableData> peers})
: _peers = peers;
required final List<PeerTableData> peers,
final String? $type})
: _peers = peers,
$type = $type ?? 'Network';
factory _$VeilidUpdateNetworkImpl.fromJson(Map<String, dynamic> json) =>
_$$VeilidUpdateNetworkImplFromJson(json);
@override
final bool started;
@ -2454,6 +2564,9 @@ class _$VeilidUpdateNetworkImpl implements VeilidUpdateNetwork {
return EqualUnmodifiableListView(_peers);
}
@JsonKey(name: 'kind')
final String $type;
@override
String toString() {
return 'VeilidUpdate.network(started: $started, bpsDown: $bpsDown, bpsUp: $bpsUp, peers: $peers)';
@ -2470,6 +2583,7 @@ class _$VeilidUpdateNetworkImpl implements VeilidUpdateNetwork {
const DeepCollectionEquality().equals(other._peers, _peers));
}
@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(runtimeType, started, bpsDown, bpsUp,
const DeepCollectionEquality().hash(_peers));
@ -2618,6 +2732,13 @@ class _$VeilidUpdateNetworkImpl implements VeilidUpdateNetwork {
}
return orElse();
}
@override
Map<String, dynamic> toJson() {
return _$$VeilidUpdateNetworkImplToJson(
this,
);
}
}
abstract class VeilidUpdateNetwork implements VeilidUpdate {
@ -2627,6 +2748,9 @@ abstract class VeilidUpdateNetwork implements VeilidUpdate {
required final BigInt bpsUp,
required final List<PeerTableData> peers}) = _$VeilidUpdateNetworkImpl;
factory VeilidUpdateNetwork.fromJson(Map<String, dynamic> json) =
_$VeilidUpdateNetworkImpl.fromJson;
bool get started;
BigInt get bpsDown;
BigInt get bpsUp;
@ -2678,13 +2802,20 @@ class __$$VeilidUpdateConfigImplCopyWithImpl<$Res>
}
/// @nodoc
@JsonSerializable()
class _$VeilidUpdateConfigImpl implements VeilidUpdateConfig {
const _$VeilidUpdateConfigImpl({required this.config});
const _$VeilidUpdateConfigImpl({required this.config, final String? $type})
: $type = $type ?? 'Config';
factory _$VeilidUpdateConfigImpl.fromJson(Map<String, dynamic> json) =>
_$$VeilidUpdateConfigImplFromJson(json);
@override
final VeilidConfig config;
@JsonKey(name: 'kind')
final String $type;
@override
String toString() {
return 'VeilidUpdate.config(config: $config)';
@ -2698,6 +2829,7 @@ class _$VeilidUpdateConfigImpl implements VeilidUpdateConfig {
(identical(other.config, config) || other.config == config));
}
@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(runtimeType, config);
@ -2845,12 +2977,22 @@ class _$VeilidUpdateConfigImpl implements VeilidUpdateConfig {
}
return orElse();
}
@override
Map<String, dynamic> toJson() {
return _$$VeilidUpdateConfigImplToJson(
this,
);
}
}
abstract class VeilidUpdateConfig implements VeilidUpdate {
const factory VeilidUpdateConfig({required final VeilidConfig config}) =
_$VeilidUpdateConfigImpl;
factory VeilidUpdateConfig.fromJson(Map<String, dynamic> json) =
_$VeilidUpdateConfigImpl.fromJson;
VeilidConfig get config;
@JsonKey(ignore: true)
_$$VeilidUpdateConfigImplCopyWith<_$VeilidUpdateConfigImpl> get copyWith =>
@ -2896,13 +3038,18 @@ class __$$VeilidUpdateRouteChangeImplCopyWithImpl<$Res>
}
/// @nodoc
@JsonSerializable()
class _$VeilidUpdateRouteChangeImpl implements VeilidUpdateRouteChange {
const _$VeilidUpdateRouteChangeImpl(
{required final List<String> deadRoutes,
required final List<String> deadRemoteRoutes})
required final List<String> deadRemoteRoutes,
final String? $type})
: _deadRoutes = deadRoutes,
_deadRemoteRoutes = deadRemoteRoutes;
_deadRemoteRoutes = deadRemoteRoutes,
$type = $type ?? 'RouteChange';
factory _$VeilidUpdateRouteChangeImpl.fromJson(Map<String, dynamic> json) =>
_$$VeilidUpdateRouteChangeImplFromJson(json);
final List<String> _deadRoutes;
@override
@ -2921,6 +3068,9 @@ class _$VeilidUpdateRouteChangeImpl implements VeilidUpdateRouteChange {
return EqualUnmodifiableListView(_deadRemoteRoutes);
}
@JsonKey(name: 'kind')
final String $type;
@override
String toString() {
return 'VeilidUpdate.routeChange(deadRoutes: $deadRoutes, deadRemoteRoutes: $deadRemoteRoutes)';
@ -2937,6 +3087,7 @@ class _$VeilidUpdateRouteChangeImpl implements VeilidUpdateRouteChange {
.equals(other._deadRemoteRoutes, _deadRemoteRoutes));
}
@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(
runtimeType,
@ -3087,6 +3238,13 @@ class _$VeilidUpdateRouteChangeImpl implements VeilidUpdateRouteChange {
}
return orElse();
}
@override
Map<String, dynamic> toJson() {
return _$$VeilidUpdateRouteChangeImplToJson(
this,
);
}
}
abstract class VeilidUpdateRouteChange implements VeilidUpdate {
@ -3095,6 +3253,9 @@ abstract class VeilidUpdateRouteChange implements VeilidUpdate {
required final List<String> deadRemoteRoutes}) =
_$VeilidUpdateRouteChangeImpl;
factory VeilidUpdateRouteChange.fromJson(Map<String, dynamic> json) =
_$VeilidUpdateRouteChangeImpl.fromJson;
List<String> get deadRoutes;
List<String> get deadRemoteRoutes;
@JsonKey(ignore: true)
@ -3165,14 +3326,19 @@ class __$$VeilidUpdateValueChangeImplCopyWithImpl<$Res>
}
/// @nodoc
@JsonSerializable()
class _$VeilidUpdateValueChangeImpl implements VeilidUpdateValueChange {
const _$VeilidUpdateValueChangeImpl(
{required this.key,
required final List<ValueSubkeyRange> subkeys,
required this.count,
required this.valueData})
: _subkeys = subkeys;
required this.valueData,
final String? $type})
: _subkeys = subkeys,
$type = $type ?? 'ValueChange';
factory _$VeilidUpdateValueChangeImpl.fromJson(Map<String, dynamic> json) =>
_$$VeilidUpdateValueChangeImplFromJson(json);
@override
final Typed<FixedEncodedString43> key;
@ -3189,6 +3355,9 @@ class _$VeilidUpdateValueChangeImpl implements VeilidUpdateValueChange {
@override
final ValueData valueData;
@JsonKey(name: 'kind')
final String $type;
@override
String toString() {
return 'VeilidUpdate.valueChange(key: $key, subkeys: $subkeys, count: $count, valueData: $valueData)';
@ -3206,6 +3375,7 @@ class _$VeilidUpdateValueChangeImpl implements VeilidUpdateValueChange {
other.valueData == valueData));
}
@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(runtimeType, key,
const DeepCollectionEquality().hash(_subkeys), count, valueData);
@ -3354,6 +3524,13 @@ class _$VeilidUpdateValueChangeImpl implements VeilidUpdateValueChange {
}
return orElse();
}
@override
Map<String, dynamic> toJson() {
return _$$VeilidUpdateValueChangeImplToJson(
this,
);
}
}
abstract class VeilidUpdateValueChange implements VeilidUpdate {
@ -3363,6 +3540,9 @@ abstract class VeilidUpdateValueChange implements VeilidUpdate {
required final int count,
required final ValueData valueData}) = _$VeilidUpdateValueChangeImpl;
factory VeilidUpdateValueChange.fromJson(Map<String, dynamic> json) =
_$VeilidUpdateValueChangeImpl.fromJson;
Typed<FixedEncodedString43> get key;
List<ValueSubkeyRange> get subkeys;
int get count;

View File

@ -114,6 +114,153 @@ Map<String, dynamic> _$$PeerTableDataImplToJson(_$PeerTableDataImpl instance) =>
'peer_stats': instance.peerStats.toJson(),
};
_$VeilidLogImpl _$$VeilidLogImplFromJson(Map<String, dynamic> json) =>
_$VeilidLogImpl(
logLevel: VeilidLogLevel.fromJson(json['log_level']),
message: json['message'] as String,
backtrace: json['backtrace'] as String?,
$type: json['kind'] as String?,
);
Map<String, dynamic> _$$VeilidLogImplToJson(_$VeilidLogImpl instance) =>
<String, dynamic>{
'log_level': instance.logLevel.toJson(),
'message': instance.message,
'backtrace': instance.backtrace,
'kind': instance.$type,
};
_$VeilidAppMessageImpl _$$VeilidAppMessageImplFromJson(
Map<String, dynamic> json) =>
_$VeilidAppMessageImpl(
message: const Uint8ListJsonConverter().fromJson(json['message']),
sender: json['sender'] == null
? null
: Typed<FixedEncodedString43>.fromJson(json['sender']),
$type: json['kind'] as String?,
);
Map<String, dynamic> _$$VeilidAppMessageImplToJson(
_$VeilidAppMessageImpl instance) =>
<String, dynamic>{
'message': const Uint8ListJsonConverter().toJson(instance.message),
'sender': instance.sender?.toJson(),
'kind': instance.$type,
};
_$VeilidAppCallImpl _$$VeilidAppCallImplFromJson(Map<String, dynamic> json) =>
_$VeilidAppCallImpl(
message: const Uint8ListJsonConverter().fromJson(json['message']),
callId: json['call_id'] as String,
sender: json['sender'] == null
? null
: Typed<FixedEncodedString43>.fromJson(json['sender']),
$type: json['kind'] as String?,
);
Map<String, dynamic> _$$VeilidAppCallImplToJson(_$VeilidAppCallImpl instance) =>
<String, dynamic>{
'message': const Uint8ListJsonConverter().toJson(instance.message),
'call_id': instance.callId,
'sender': instance.sender?.toJson(),
'kind': instance.$type,
};
_$VeilidUpdateAttachmentImpl _$$VeilidUpdateAttachmentImplFromJson(
Map<String, dynamic> json) =>
_$VeilidUpdateAttachmentImpl(
state: AttachmentState.fromJson(json['state']),
publicInternetReady: json['public_internet_ready'] as bool,
localNetworkReady: json['local_network_ready'] as bool,
$type: json['kind'] as String?,
);
Map<String, dynamic> _$$VeilidUpdateAttachmentImplToJson(
_$VeilidUpdateAttachmentImpl instance) =>
<String, dynamic>{
'state': instance.state.toJson(),
'public_internet_ready': instance.publicInternetReady,
'local_network_ready': instance.localNetworkReady,
'kind': instance.$type,
};
_$VeilidUpdateNetworkImpl _$$VeilidUpdateNetworkImplFromJson(
Map<String, dynamic> json) =>
_$VeilidUpdateNetworkImpl(
started: json['started'] as bool,
bpsDown: BigInt.parse(json['bps_down'] as String),
bpsUp: BigInt.parse(json['bps_up'] as String),
peers:
(json['peers'] as List<dynamic>).map(PeerTableData.fromJson).toList(),
$type: json['kind'] as String?,
);
Map<String, dynamic> _$$VeilidUpdateNetworkImplToJson(
_$VeilidUpdateNetworkImpl instance) =>
<String, dynamic>{
'started': instance.started,
'bps_down': instance.bpsDown.toString(),
'bps_up': instance.bpsUp.toString(),
'peers': instance.peers.map((e) => e.toJson()).toList(),
'kind': instance.$type,
};
_$VeilidUpdateConfigImpl _$$VeilidUpdateConfigImplFromJson(
Map<String, dynamic> json) =>
_$VeilidUpdateConfigImpl(
config: VeilidConfig.fromJson(json['config']),
$type: json['kind'] as String?,
);
Map<String, dynamic> _$$VeilidUpdateConfigImplToJson(
_$VeilidUpdateConfigImpl instance) =>
<String, dynamic>{
'config': instance.config.toJson(),
'kind': instance.$type,
};
_$VeilidUpdateRouteChangeImpl _$$VeilidUpdateRouteChangeImplFromJson(
Map<String, dynamic> json) =>
_$VeilidUpdateRouteChangeImpl(
deadRoutes: (json['dead_routes'] as List<dynamic>)
.map((e) => e as String)
.toList(),
deadRemoteRoutes: (json['dead_remote_routes'] as List<dynamic>)
.map((e) => e as String)
.toList(),
$type: json['kind'] as String?,
);
Map<String, dynamic> _$$VeilidUpdateRouteChangeImplToJson(
_$VeilidUpdateRouteChangeImpl instance) =>
<String, dynamic>{
'dead_routes': instance.deadRoutes,
'dead_remote_routes': instance.deadRemoteRoutes,
'kind': instance.$type,
};
_$VeilidUpdateValueChangeImpl _$$VeilidUpdateValueChangeImplFromJson(
Map<String, dynamic> json) =>
_$VeilidUpdateValueChangeImpl(
key: Typed<FixedEncodedString43>.fromJson(json['key']),
subkeys: (json['subkeys'] as List<dynamic>)
.map(ValueSubkeyRange.fromJson)
.toList(),
count: json['count'] as int,
valueData: ValueData.fromJson(json['value_data']),
$type: json['kind'] as String?,
);
Map<String, dynamic> _$$VeilidUpdateValueChangeImplToJson(
_$VeilidUpdateValueChangeImpl instance) =>
<String, dynamic>{
'key': instance.key.toJson(),
'subkeys': instance.subkeys.map((e) => e.toJson()).toList(),
'count': instance.count,
'value_data': instance.valueData.toJson(),
'kind': instance.$type,
};
_$VeilidStateAttachmentImpl _$$VeilidStateAttachmentImplFromJson(
Map<String, dynamic> json) =>
_$VeilidStateAttachmentImpl(