plebble
peer_t.h
Go to the documentation of this file.
1 /*
2 -------------------------------------------------------------------------------
3  PLEBBLE
4 -------------------------------------------------------------------------------
5  Copyright (C) 2019-2020 KATLAS Technology. (http://katlastechnology.com)
6  Copyright (C) 2017-2020 Marcos Mayorga. (mm@mm-studios.com)
7 
8  This file is part of our Plebble(R) Platform.
9 
10  The code below cannot be copied, used for any purpose other than the one
11  agreed and/or distributed without the express permission of
12  KATLAS Technology.
13 -------------------------------------------------------------------------------
14 
15 
16 */
17 #ifndef USGOV_e71c29d5f8c07b8000435dfe6a5f1e49605b1b2041dad14a3ac898464ed5dd49
18 #define USGOV_e71c29d5f8c07b8000435dfe6a5f1e49605b1b2041dad14a3ac898464ed5dd49
19 
20 #include <us/gov/auth/peer_t.h>
21 #include <vector>
22 #include <thread>
23 #include <iostream>
24 #include <algorithm>
25 #include <sstream>
26 #include <chrono>
27 #include <cassert>
28 #include <array>
29 #include <unordered_set>
30 #include <us/gov/config.h>
31 
32 namespace us { namespace gov {
33 namespace peer {
34  using namespace std;
35  struct daemon;
36  using us::ko;
37 
38  struct peer_t: auth::peer_t {
39  typedef auth::peer_t b;
41 
42  enum stage_t {
43  stage_disconnected=0,
48  num_stages
49  };
50  constexpr static array<const char*,num_stages> stagestr={"disconnected", "connected", "latency", "service", "disconnecting"};
51  constexpr static chrono::seconds auth_window{socket::peer_t::stall+5s};
52  constexpr static uint64_t maxidle_ms{180000};
53  static const char* finished_reason_1;
54 
55  peer_t(int sock);
56  ~peer_t() override;
57  ko connect(uint32_t host, uint16_t port, uint16_t pport, role_t, bool block) override;
58  void disconnect(uint16_t seq, const string& reason) override;
59  void dump_all(const string& prefix, ostream& os) const override;
61  bool check_auth_not_granted() const;
62  bool check_idle() const;
63  void dump(const string& prefix, ostream& os) const;
64  bool authorize(const pub_t& p, uint16_t pin) const override;
65 
67  };
68 
69 }
70 }}
71 
72 #endif
73 
us::gov::peer::peer_t::stage_service
@ stage_service
Definition: peer_t.h:46
us::gov::auth::peer_t::stage_t
stage_t
Definition: peer_t.h:29
us::gov::socket::client.pair
Definition: client.cs:143
us::gov::id::peer_t::role_t
role_t
Definition: peer_t.h:52
us.ko
Definition: ko.java:20
us::gov::peer::peer_t::dump
void dump(const string &prefix, ostream &os) const
us::gov::peer::peer_t::b
auth::peer_t b
Definition: peer_t.h:39
us
Definition: daemon.h:22
us::gov::peer::peer_t::connect
ko connect(uint32_t host, uint16_t port, uint16_t pport, role_t, bool block) override
us::gov::peer::peer_t::finished_reason_1
static const char * finished_reason_1
Definition: peer_t.h:53
us::gov::peer::peer_t::~peer_t
~peer_t() override
us::gov::crypto::ec::keys::pub_t
Definition: ec.h:44
us::gov::socket::datagram
Definition: datagram.h:44
us::gov::auth::daemon
id::daemon daemon
Definition: daemon.h:25
us::gov::auth::peer_t
Definition: peer_t.h:27
us::gov::peer::peer_t::authorize
bool authorize(const pub_t &p, uint16_t pin) const override
us::gov::peer::peer_t::stage_disconnecting
@ stage_disconnecting
Definition: peer_t.h:47
us::gov::peer::peer_t::peer_t
peer_t(int sock)
us::gov::peer::peer_t::stage_connected
@ stage_connected
Definition: peer_t.h:44
us::gov::peer::peer_t::stage_exceed_latency
@ stage_exceed_latency
Definition: peer_t.h:45
us::gov::peer::peer_t
Definition: peer_t.h:38
us::ko
const ko_t * ko
Definition: ko.h:27
us::gov::peer::peer_t::check_auth_not_granted
bool check_auth_not_granted() const
us::gov::peer::peer_t::security_level
pair< security_level_t, string > security_level() const override
us::gov::peer::peer_t::stage
stage_t stage
Definition: peer_t.h:66
std
Definition: app.h:380
peer_t.h
us::gov::peer::peer_t::check_idle
bool check_idle() const
config.h
us::gov::socket::peer_t::stall
constexpr static chrono::seconds stall
Definition: peer_t.h:31
us::gov::peer::peer_t::dump_all
void dump_all(const string &prefix, ostream &os) const override
us::gov::peer::peer_t::disconnect
void disconnect(uint16_t seq, const string &reason) override