Skip to content

Commit c828e03

Browse files
Merge pull request #446 from helium/mj/hotspot-banning
Hotspot Banning
2 parents 5686762 + a53e6d6 commit c828e03

File tree

3 files changed

+82
-4
lines changed

3 files changed

+82
-4
lines changed

beacon/src/region.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ impl Default for Region {
7676

7777
impl Region {
7878
pub fn from_i32(v: i32) -> Result<Self> {
79-
ProtoRegion::from_i32(v)
79+
ProtoRegion::try_from(v)
8080
.map(Self)
81-
.ok_or_else(|| Error::unsupported_region(v))
81+
.map_err(|_| Error::unsupported_region(v))
8282
}
8383

8484
pub fn is_unknown(&self) -> bool {
@@ -214,8 +214,8 @@ impl RegionParams {
214214
})
215215
// Convert to RegionSpreading
216216
.and_then(|region_spreading| {
217-
RegionSpreading::from_i32(region_spreading)
218-
.ok_or_else(|| Error::unsupported_region_spreading(region_spreading))
217+
RegionSpreading::try_from(region_spreading)
218+
.map_err(|_| Error::unsupported_region_spreading(region_spreading))
219219
})
220220
}
221221

src/service/mobile_config.proto

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,17 @@ enum admin_key_role {
213213
carrier = 3;
214214
// propagation calculation service of a mobile carrier
215215
pcs = 4;
216+
// key for signing ban requests
217+
admin_key_role_banning = 5;
216218
}
217219

218220
enum network_key_role {
219221
mobile_carrier = 0;
220222
mobile_router = 1;
221223
// Keys from the Propagation Calculation Service
222224
mobile_pcs = 2;
225+
// Key for signing ban requests
226+
network_key_role_banning = 3;
223227
}
224228

225229
enum device_type {

src/service/poc_mobile.proto

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,79 @@ service poc_mobile {
394394
returns (unique_connections_resp_v1);
395395
rpc submit_subscriber_mapping_activity(subscriber_mapping_activity_req_v1)
396396
returns (subscriber_mapping_activity_res_v1);
397+
rpc submit_ban(ban_req_v1) returns (ban_resp_v1);
398+
}
399+
400+
message ban_resp_v1 { uint64 timestamp_ms = 1; }
401+
402+
message ban_req_v1 {
403+
// Address of the hotspot being banned
404+
bytes hotspot_pubkey = 1;
405+
// Timestamp in milliseconds the message was sent
406+
uint64 timestamp_ms = 3;
407+
// Signer of the message
408+
bytes ban_pubkey = 5;
409+
bytes signature = 6;
410+
411+
oneof ban_action {
412+
ban_details_v1 ban = 7;
413+
unban_details_v1 unban = 8;
414+
}
415+
}
416+
417+
message ban_details_v1 {
418+
// Helpful to have for display purposes
419+
string hotspot_serial = 2;
420+
string message = 3;
421+
ban_reason reason = 4;
422+
ban_type ban_type = 5;
423+
// Timestamp in milliseconds that the ban should expire
424+
// if not replaced by a subsequent ban.
425+
// Note: 0 value means no expiration.
426+
uint64 expiration_timestamp_ms = 6;
427+
}
428+
429+
enum ban_reason {
430+
ban_reason_unknown = 0;
431+
ban_reason_location_gaming = 1;
432+
ban_reason_data_farming = 2;
433+
}
434+
435+
message unban_details_v1 {
436+
// Helpful to have for display purposes
437+
string hotspot_serial = 2;
438+
string message = 3;
439+
}
440+
441+
enum ban_type {
442+
// Banned from receiving POC and Data Transfer rewards
443+
all = 0;
444+
// Banned from receiving only POC
445+
poc = 1;
446+
// Banned from receiving only Data Transfer rewards
447+
data = 2;
448+
}
449+
450+
// All ban messages received by the Ingester.
451+
message ban_ingest_report_v1 {
452+
// Timstamp in milliseconds since unix epoch
453+
uint64 received_timestamp_ms = 1;
454+
ban_req_v1 report = 2;
455+
}
456+
457+
enum verified_ban_ingest_report_status {
458+
verified_ban_ingest_report_status_valid = 0;
459+
verified_ban_ingest_report_status_invalid_ban_key = 1;
460+
}
461+
462+
// Ban messages signed by a valid key in the Verifier.
463+
message verified_ban_ingest_report_v1 {
464+
// Timestamp in milliseconds the report was verified by oracles
465+
uint64 verified_timestamp_ms = 1;
466+
// The verified report
467+
ban_ingest_report_v1 report = 2;
468+
469+
verified_ban_ingest_report_status status = 3;
397470
}
398471

399472
message unique_connections_req_v1 {
@@ -857,6 +930,7 @@ message verified_data_transfer_ingest_report_v1 {
857930
invalid_gateway_key = 1;
858931
invalid_routing_key = 2;
859932
duplicate = 3;
933+
banned = 4;
860934
}
861935
data_transfer_session_ingest_report_v1 report = 1;
862936
report_status status = 2;

0 commit comments

Comments
 (0)