github.com/ZuluSpl0it/Sia@v1.3.7/modules/gateway.go (about) 1 package modules 2 3 import ( 4 "net" 5 6 "github.com/NebulousLabs/Sia/build" 7 ) 8 9 const ( 10 // GatewayDir is the name of the directory used to store the gateway's 11 // persistent data. 12 GatewayDir = "gateway" 13 ) 14 15 var ( 16 // BootstrapPeers is a list of peers that can be used to find other peers - 17 // when a client first connects to the network, the only options for 18 // finding peers are either manual entry of peers or to use a hardcoded 19 // bootstrap point. While the bootstrap point could be a central service, 20 // it can also be a list of peers that are known to be stable. We have 21 // chosen to hardcode known-stable peers. 22 BootstrapPeers = build.Select(build.Var{ 23 Standard: []NetAddress{ 24 "23.175.0.151:9981", 25 "51.15.48.114:9981", 26 "137.74.1.200:9981", 27 "23.239.14.98:9971", 28 "23.239.14.98:9981", 29 "162.211.163.190:9981", 30 "67.254.219.180:9981", 31 "108.28.206.98:9981", 32 "162.211.163.189:9981", 33 "192.254.68.245:9981", 34 "69.125.184.202:9981", 35 "66.49.218.20:9981", 36 "66.49.218.102:9981", 37 "72.229.14.109:9981", 38 "209.182.216.47:9981", 39 "65.30.45.202:9981", 40 "174.58.166.159:9981", 41 "147.135.132.95:9981", 42 "88.202.202.221:9981", 43 "51.15.41.218:9981", 44 "147.135.133.105:9981", 45 "147.135.133.100:9981", 46 "94.23.7.123:9981", 47 "24.125.195.213:9981", 48 "107.181.137.139:9981", 49 "67.207.162.194:9981", 50 "147.135.132.94:9981", 51 "94.23.54.36:9981", 52 "147.135.133.114:9981", 53 "72.24.114.182:9981", 54 "85.27.163.135:9981", 55 "77.132.24.85:9981", 56 "62.210.140.24:9981", 57 "217.160.178.117:9981", 58 "80.239.147.28:9981", 59 "94.137.140.40:9981", 60 "193.248.47.218:9981", 61 "85.214.229.44:9981", 62 "138.68.84.69:9981", 63 "93.103.248.239:9981", 64 "76.28.239.179:9981", 65 "76.174.155.33:9984", 66 "94.225.83.165:9981", 67 "78.41.116.91:9981", 68 "51.175.10.196:9981", 69 "188.242.52.10:9988", 70 "188.242.52.10:9986", 71 "5.20.184.133:9981", 72 "81.167.50.168:9981", 73 "83.142.60.64:9981", 74 "85.21.232.162:9981", 75 "188.244.40.69:9985", 76 "188.244.40.69:9981", 77 "95.78.166.67:9981", 78 "109.194.162.16:9981", 79 "78.248.218.28:9981", 80 "217.173.23.149:9981", 81 "91.231.94.22:9981", 82 "27.120.81.167:9981", 83 "162.211.163.188:9981", 84 "122.214.1.30:9981", 85 "94.201.207.205:9981", 86 "71.65.230.65:9332", 87 "109.248.206.13:9981", 88 "114.55.95.111:9981", 89 "47.94.45.200:9981", 90 "121.254.64.110:9981", 91 "45.56.21.129:9981", 92 "188.242.52.10:9981", 93 "116.62.118.38:30308", 94 "174.138.20.196:9981", 95 "71.199.19.26:9981", 96 "78.46.64.86:9981", 97 "115.70.170.117:9981", 98 "203.87.65.150:9981", 99 "75.82.191.146:19981", 100 "163.172.215.185:9981", 101 "108.162.149.228:9981", 102 "69.172.174.21:9981", 103 "91.206.15.126:9981", 104 "13.93.44.96:9981", 105 "188.244.40.69:9997", 106 "92.70.88.30:9981", 107 "109.173.126.111:9981", 108 "5.9.139.30:9981", 109 "213.239.221.175:9981", 110 "66.49.218.179:9981", 111 "163.172.209.161:9981", 112 "101.200.202.108:9981", 113 "24.6.98.156:9981", 114 "162.211.163.187:9981", 115 "176.9.51.183:9981", 116 "87.249.251.18:9981", 117 "74.107.124.167:9981", 118 "163.172.18.134:9981", 119 "176.9.144.99:9981", 120 "45.22.40.217:9981", 121 "62.210.93.142:9981", 122 "80.108.192.203:9981", 123 "5.57.198.66:9981", 124 "147.135.133.117:9981", 125 }, 126 Dev: []NetAddress(nil), 127 Testing: []NetAddress(nil), 128 }).([]NetAddress) 129 ) 130 131 type ( 132 // Peer contains all the info necessary to Broadcast to a peer. 133 Peer struct { 134 Inbound bool `json:"inbound"` 135 Local bool `json:"local"` 136 NetAddress NetAddress `json:"netaddress"` 137 Version string `json:"version"` 138 } 139 140 // A PeerConn is the connection type used when communicating with peers during 141 // an RPC. It is identical to a net.Conn with the additional RPCAddr method. 142 // This method acts as an identifier for peers and is the address that the 143 // peer can be dialed on. It is also the address that should be used when 144 // calling an RPC on the peer. 145 PeerConn interface { 146 net.Conn 147 RPCAddr() NetAddress 148 } 149 150 // RPCFunc is the type signature of functions that handle RPCs. It is used for 151 // both the caller and the callee. RPCFuncs may perform locking. RPCFuncs may 152 // close the connection early, and it is recommended that they do so to avoid 153 // keeping the connection open after all necessary I/O has been performed. 154 RPCFunc func(PeerConn) error 155 156 // A Gateway facilitates the interactions between the local node and remote 157 // nodes (peers). It relays incoming blocks and transactions to local modules, 158 // and broadcasts outgoing blocks and transactions to peers. In a broad sense, 159 // it is responsible for ensuring that the local consensus set is consistent 160 // with the "network" consensus set. 161 Gateway interface { 162 // Connect establishes a persistent connection to a peer. 163 Connect(NetAddress) error 164 165 // Disconnect terminates a connection to a peer. 166 Disconnect(NetAddress) error 167 168 // Address returns the Gateway's address. 169 Address() NetAddress 170 171 // Peers returns the addresses that the Gateway is currently connected to. 172 Peers() []Peer 173 174 // RegisterRPC registers a function to handle incoming connections that 175 // supply the given RPC ID. 176 RegisterRPC(string, RPCFunc) 177 178 // UnregisterRPC unregisters an RPC and removes all references to the RPCFunc 179 // supplied in the corresponding RegisterRPC call. References to RPCFuncs 180 // registered with RegisterConnectCall are not removed and should be removed 181 // with UnregisterConnectCall. If the RPC does not exist no action is taken. 182 UnregisterRPC(string) 183 184 // RegisterConnectCall registers an RPC name and function to be called 185 // upon connecting to a peer. 186 RegisterConnectCall(string, RPCFunc) 187 188 // UnregisterConnectCall unregisters an RPC and removes all references to the 189 // RPCFunc supplied in the corresponding RegisterConnectCall call. References 190 // to RPCFuncs registered with RegisterRPC are not removed and should be 191 // removed with UnregisterRPC. If the RPC does not exist no action is taken. 192 UnregisterConnectCall(string) 193 194 // RPC calls an RPC on the given address. RPC cannot be called on an 195 // address that the Gateway is not connected to. 196 RPC(NetAddress, string, RPCFunc) error 197 198 // Broadcast transmits obj, prefaced by the RPC name, to all of the 199 // given peers in parallel. 200 Broadcast(name string, obj interface{}, peers []Peer) 201 202 // Online returns true if the gateway is connected to remote hosts 203 Online() bool 204 205 // Close safely stops the Gateway's listener process. 206 Close() error 207 } 208 )