forked from stellar/stellar-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPeerBareAddress.h
70 lines (55 loc) · 1.4 KB
/
PeerBareAddress.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#pragma once
// Copyright 2018 Stellar Development Foundation and contributors. Licensed
// under the Apache License, Version 2.0. See the COPYING file at the root
// of this distribution or at http://www.apache.org/licenses/LICENSE-2.0
#include "main/Config.h"
#include "xdr/Stellar-overlay.h"
namespace stellar
{
class Application;
class PeerBareAddress
{
public:
enum class Type
{
EMPTY,
IPv4
};
PeerBareAddress();
explicit PeerBareAddress(std::string ip, unsigned short port);
explicit PeerBareAddress(PeerAddress const& pa);
static PeerBareAddress
resolve(std::string const& ipPort, Application& app,
unsigned short defaultPort = DEFAULT_PEER_PORT);
bool
isEmpty() const
{
return mType == Type::EMPTY;
}
Type
getType() const
{
return mType;
}
std::string const&
getIP() const
{
return mIP;
}
unsigned short
getPort() const
{
return mPort;
}
std::string toString() const;
bool isPrivate() const;
bool isLocalhost() const;
friend bool operator==(PeerBareAddress const& x, PeerBareAddress const& y);
friend bool operator!=(PeerBareAddress const& x, PeerBareAddress const& y);
friend bool operator<(PeerBareAddress const& x, PeerBareAddress const& y);
private:
Type mType;
std::string mIP;
unsigned short mPort;
};
}