Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
60fbc453d6
  1. 1
      SuperNET/SuperNET.h
  2. 1772
      agents/BTCD_hdrs.txt
  3. 49
      agents/BTCD_peers.txt
  4. 195
      agents/BTC_hdrs.txt
  5. 137
      agents/BTC_peers.txt
  6. 93
      crypto777/curve25519.c
  7. 3
      crypto777/iguana_OS.c
  8. 465
      iguana/SuperNET.c
  9. 19
      iguana/SuperNET.h
  10. 2
      iguana/iguana.sources
  11. 3
      iguana/main.c
  12. 4
      includes/curve25519.h

1
SuperNET/SuperNET.h

@ -25,6 +25,7 @@
#define SUPERNET_POLLTIMEOUT 1
#define SUPERNET_APIUSLEEP (SUPERNET_POLLTIMEOUT * 10000)
#define SUPERNET_MAXAGENTS 64
#define MAX_SERVERNAME 128
#define LB_OFFSET 1
#define PUBGLOBALS_OFFSET 2

1772
agents/BTCD_hdrs.txt

File diff suppressed because it is too large

49
agents/BTCD_peers.txt

@ -1,49 +0,0 @@
78.47.58.62
67.212.70.88
94.102.50.69
50.179.58.158
194.135.94.30
109.236.85.42
104.236.127.154
68.45.147.145
37.59.14.7
78.47.115.250
188.40.138.8
62.75.143.120
82.241.71.230
217.23.6.2
73.28.172.128
45.55.149.34
192.0.242.54
81.181.155.53
91.66.185.97
85.25.217.233
144.76.239.66
95.80.9.112
80.162.193.118
173.65.129.85
2.26.173.58
78.14.250.69
188.226.253.77
58.107.67.39
124.191.37.212
176.226.137.238
69.145.25.85
24.168.14.28
73.201.180.47
76.188.171.53
63.247.147.166
121.108.241.247
36.74.36.125
106.186.119.171
188.166.91.37
223.134.228.208
89.248.160.244
178.33.209.212
71.53.156.38
88.198.10.165
24.117.221.0
74.14.104.57
158.69.27.82
110.174.129.213
75.130.163.51

195
agents/BTC_hdrs.txt

@ -1,195 +0,0 @@
386001
0 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
2000 00000000dfd5d65c9d8561b4b8f60a63018fe3933ecb131fb37f905f87da951a
4000 00000000922e2aa9e84a474350a3555f49f06061fd49df50a9352f156692a842
6000 00000000dbbb79792303bdd1c6c4d7ab9c21bba0667213c2eca955e11230c5a5
8000 0000000094fbacdffec05aea9847000522a258c269ae37a74a818afb96fc27d9
10000 0000000099c744455f58e6c6e98b671e1bf7f37346bfd4cf5d0274ad8ee660cb
12000 0000000011d1d9f1af3e1d038cebba251f933102dbe181d46a7966191b3299ee
14000 000000002d9050318ec8112057423e30b9570b39998aacd00ca648216525fce3
16000 00000000679a1ab3af6da03f13a0bc96d7215e65458b2d2edfa030b5b431e8b3
18000 00000000f914f0d0692e56bd06565ac4de668251b6a29fe0535d1e0031cfd0de
20000 00000000770ebe897270ca5f6d539d8afb4ea4f4e757761a34ca82e17207d886
22000 000000004625a14242beccb38c63a1f770a76ee5788764e6c0abd4129bbc1b9d
24000 00000000f04fccc81f37002707e9501a3f7bdcf25f65531f386a2da8af20122e
26000 000000006d6c151db6d4d67356d590a897a11cd7d8111ee989de6f2f548410bf
28000 00000000172c5ed49d7dfc29bf9a18a53fa2d050fa37aa210d6d4080fd0c7e67
30000 00000000de1250dc2df5cf4d877e055f338d6ed1ab504d5b71c097cdccd00e13
32000 00000000049172ba3ec1b673cf13e3d0049c1c07bb103ed3fa300e3833480055
34000 00000000495968d19210d3be15bd24fdc19805a0ef15026b0bb4482b04a9da3c
36000 0000000080c3deea35dc3df90a5fbe5f27db52f5e01018ae7d62f8b454c71335
38000 000000002dfebce284d1e08b6cf04452530891579b7377669865889498de8f3f
40000 00000000504d5fa0ad2cb90af16052a4eb2aea70fa1cba653b90a4583c5193e4
42000 000000000f80c09687893406279f62da437a6a0b95b8dc096b30c10ce088fc64
44000 000000000122898b31073a770a97cf599c00672fc8d6ae15652235862f8b76d8
46000 000000001dd39771dbe4f9fc6da07327f13f894dd2c1a46cdfcedf930fbbc52b
48000 000000000f3d40ea2bfa8d779010e52cff4720c072ec4b12ed576cf5cf93c947
50000 000000001aeae195809d120b5d66a39c83eb48792e068f8ea1fea19d84a4278a
52000 00000000082bc4398c4aa5bd8d9fc452d60d533ef68baabf594c9e7d6649049f
54000 00000000144197f54afa21ae7db2bc93eee604432101fc0ebe7966a52bb27e61
56000 000000000dfa452ea45e0426dd8914c35e24dfd4399037c5e6deb9f18f58d6d3
58000 0000000013e3791d288d9db814c52fbdf240b2206eb8e19d7dc80013c60c0c00
60000 000000000b554c46f8eb7264d7d5e334382c6fc3098dabf734de37962ccd7495
62000 0000000006dd4bc72daabef992f860e703820de119af3e24a1ea6f6c81521011
64000 0000000003d7055b51d7b9ab693de84c03201fe0396af61dbb30bf31445d3f55
66000 00000000071d7e8a0f4895e60c1073df9311d65a85244be1ee6369c9506281af
68000 0000000000d991791fdfdbccbbc2a73d2f86ccf78e2d0a7ce7675f40b5986b3e
70000 00000000002b8cd0faa58444df3ba2a22af2b5838c7e4a5b687444f913a575c2
72000 0000000000eb357d4c6fef6ad9a6fade126985ad36042a99cf215a4454545977
74000 0000000000573993a3c9e41ce34471c079dcf5f52a0e824a81e7f953b8661a20
76000 0000000000571138ff757a28ddf9b56f28c4a461e170660bb5ae79a556069bb6
78000 00000000001f3fe62641b473673c9ababbe207046a109f0861af95c905a918fa
80000 000000000043a8c0fd1d6f726790caa2a406010d19efd2780db27bdbbd93baf6
82000 00000000000c9d1c4acc114afb58d55db5ec44a963263cf6247220b7a3f85c5c
84000 00000000001385326e30864192ba84ed2f9cbfadf0698655b1c25f93c92f22ad
86000 000000000000ff4e1adb14f07774dad6b34968a5e19d1a2fe1fc9157e7c2b85d
88000 00000000000ae9e98b82b39a912cdc0ebed97c26376780ac996c84d9ec3264a4
90000 0000000000071694daf735a6b5da101d77a04c7e6008c680e461f0025ba7b7af
92000 0000000000001df90b0c523a4d7e4731336b00cf4ba9d8e02d111523df80998c
94000 000000000002a4c42580d51f0ddfd867eaaa790781c484c633a69167d17b48ec
96000 000000000002c86b568cdd2d0f4b0430cccf42bcde3361f63a32e23b5d839e99
98000 000000000002272a6dfb695d9db936d813bf0055ae92e920c2791d4c5f7290f1
100000 000000000003ba27aa200b1cecaad478d2b00432346c3f1f3986da1afd33e506
102000 00000000000335c47dd6ae953912d172a4d9839355f2083165043bb6f43c2f58
104000 000000000000a9887c91956b638bb3c0651321fdb24715354c3fc6633f5a16a3
106000 00000000000058d919f52d255f394ed0aa3a344432676fd30f1aab4e10c22fad
108000 00000000000167cea0b43ff7ce22f330d3e302832187eb31c61b15bb1511e118
110000 000000000001bbda3f22ef8e476b470a2d3ae16821c23a6d22db77318d0799a9
112000 0000000000001d69b3899a49f37799c375a7471829953d5470f468f48ff70432
114000 0000000000003195a1e6dc48a540264d37e9ef79b552bd78ea4b93a3b6e7e449
116000 00000000000007ff257fb2edd3fdbd7b00c127a66dae1288fc5e26c402d13bf7
118000 000000000000774a7f8a7a12dc906ddb9e17e75d684f15e00f8767f9e8f36553
120000 0000000000000e07595fca57b37fea8522e95e0f6891779cfd34d7e537524471
122000 0000000000002fe5f29af38282ac1c8f4ea2bf8a0855946150130419491b6c05
124000 00000000000023e9a0523cfac29afe07a07acf81e273cd892c51ff8318846620
126000 000000000000166b7d480aada35af1e6f9a2835d68f9c2fbd272073dc6c9d5fb
128000 00000000000003b8ddd8692769e1965554a8bb030863e0566a28bc0dc952864e
130000 00000000000011906b491883ab0f16f0e690b133ca860b199b775c3cf6581c21
132000 00000000000000a7a0483857f0d951983ff2834a47c38fdcc22563ac0f8f707b
134000 00000000000007e3e442ce1423496a064a7c34342ba98be164ac0c9f9b872213
136000 00000000000004da0d6d69fd474fa08fe2ff3111ff1e9e01f72899dcd9d897f0
138000 0000000000000044c7b6a5511c0b2ae64ec545abccac8053f31cf7bba23bb886
140000 000000000000086e28cf4717a80066def0ec26c53d660582bd997221fef297db
142000 00000000000006379826f5f10cd23739b9c29f87ca10f199f9f4b72006311f85
144000 0000000000000681a73f1bb50454cee419048d24e1091bcddadded89df53fd07
146000 0000000000000188cbeebda87456f040370995dc11eb3a1e76b1577b6e0b588d
148000 00000000000008be94b219a94752bde6a6a1c5b9d72abf2aaab53df7d93c5fa6
150000 0000000000000a3290f20e75860d505ce0e948a1d1d846bec7e39015d242884b
152000 0000000000000aca2b3a267dab498adc48afd15b60cbf21fa58dc26c86a6dc13
154000 0000000000000a7446d1a63b8229670aa02d1d9fdfd729b89107fe5d88dacd8e
156000 00000000000002adfcffbd5f09744ae3b930597dd0ea684cd37b816783ba3762
158000 00000000000000e50d56f13c7ce64183386abcac63462ca745b711be27568f52
160000 000000000000066c6e629b2fb49c7fcc52b82fe9833f328e0c3943856facf231
162000 00000000000001a83f5b20cd132f38f792fc02a17eb14d494c780ea9d1c82acc
164000 00000000000005a38f162cf308edea0a0a5d000bdb2073cba2386ebb1df7a2cf
166000 00000000000003b3402f35327d144a465f3768d6e6cb06cd8a2d8fc1328b2477
168000 000000000000099e61ea72015e79632f216fe6cb33d7899acb35b75c8303b763
170000 000000000000051f68f43e9d455e72d9c4e4ce52e8a00c5e24c07340632405cb
172000 0000000000000837e82c3a4ebe35a1d1d943e056234dba7c629922c6d4052d4c
174000 0000000000000504d3e701deb624eee4370f50c3d688fd1c27be5bbef07d76dd
176000 00000000000004659b5b8602b2132b62973994079a1c828df6ef8d6427e4686b
178000 00000000000009eae2697a7aaf57e730b707b9f4530449c16d924d534d41f297
180000 00000000000004ff83b6c10460b239ef4a6aa320e5fffd6c7bcedefa8c78593c
182000 000000000000068dce12903c1447e4c5b60311b61e443a25d5fc82c77f4f9a8f
184000 000000000000060405a235c6b968ccb18fd6b3800ae9742c2524e28863367359
186000 000000000000072ede9629fd1fd1af3cc2baa0e637f1959f34884be0e160dd1c
188000 000000000000004cf0c72d6dedfde88ca4c3dae129563210072ee68acded0ab1
190000 0000000000000708bf3b261ffc963b6a768d915f9cfc9ec0a6c2a09969efad1a
192000 00000000000000af130d565291ba49208c546685c69b48a293aaf06387fc22ef
194000 000000000000046242d4984ecf2217e9afa113f2835bffbff118f2df4d80b216
196000 00000000000006ae59396d4a289e83fe1b9967630752a5799f064620af7836a9
198000 000000000000000f2ad431ff18ab1673d911395c8fa1f6801e054c5dcb54f8fb
200000 000000000000034a7dedef4a161fa058a2d67a173a90155f3a2fe6fc132e0ebf
202000 00000000000003282fe1d5533e4275fd9f51e6ba0352ec01f32914e9fbaeaf55
204000 0000000000000423eb625dc140272ab97fea3ba6baf1dc56de77deabcc492872
206000 0000000000000130b815d40fd6d8851438cd21ac9e428615ba03a1285ef1374c
208000 000000000000001db5a1515a5f8534c941b1628f60466e6b709b3b320254afff
210000 000000000000048b95347e83192f69cf0366076336c639f9b7228e9ba171342e
212000 00000000000003d906e4131c39f7655b72df40146d2967f5d75113a09610de61
214000 00000000000003e6427f9fafa8b0e1af0859f15cea90d911f64445d296a2781a
216000 00000000000001f79a2db15d0ec6d951729e044749372caf504679bba5b1e65e
218000 0000000000000569070e338293af66258adba29dcdd5f33212314dff752ff458
220000 000000000000002fdd2c741ed50bc3975a640ca419081711f30f553939641303
222000 00000000000002c752a481ce0c45450ab046e640d38d6532178721e7700d8148
224000 0000000000000107ee276d037218bf1780dbf6d4256bd7e05c66ca133bbc9ac5
226000 000000000000012c614cf477c3b155d339f29d565c0258f9846c2f4dd402ff9b
228000 00000000000000efc4311c93fafbccedb6fdc682b566cba9519f1736b9788a67
230000 000000000000012cfb19f5662707816e122ad60dd9b1cd646c6c9899be2c9667
232000 000000000000018f47636e1c3a946db77624880ae484ffb0233f5aac6316b3bb
234000 00000000000000597f9263ea97bed4d3b10fbd55733a73bd1027f1a9b6c1451a
236000 00000000000000f2f5e55e89dde082cecc9b4a46a10bbb4197f5e35b16612db5
238000 000000000000010014007d4b51ab60063684665401e448c6b0b1971a7398a442
240000 000000000000000e7ad69c72afc00dc4e05fc15ae3061c47d3591d07c09f2928
242000 00000000000000c95233d37a8c78dff10afecb14060347151b7eb7a04a2a5a3c
244000 000000000000006ded1526017d5b87ca22e1bd0da3921872cc99e9ec77ee5166
246000 000000000000004c318a3ad2ebac28d140fada215b11f5b7d8e9151ff0b000af
248000 000000000000004d945017c14b75a3a58a2aa6772cacbfcaf907b3bee6d7f344
250000 000000000000003887df1f29024b06fc2200b55f8af8f35453d7be294df2d214
252000 00000000000000200e99940b296ded4ce16462bba1950453b29abf313ba7cc47
254000 000000000000004753be91559a2c74c6cb8a5d2be6db1df2ca0b2385697e53ff
256000 00000000000000252b217c0ce5c4d96b825b90dacbe8e4dcf5f6a8ba6749f3c2
258000 00000000000000159f682a983465761f471dd24300746efe8db5642411f1b631
260000 000000000000001fb91fbcebaaba0e2d926f04908d798a8b598c3bd962951080
262000 000000000000001002ac67e026c523c3779b1ff2e3b9e2b7bfa6022ee1afae2a
264000 000000000000000d05c31485c532503939ca0b88d7e322dff79900ee6cdd5ed4
266000 0000000000000009d755c65d58c7c1fde9167ba632a85574de3bb11c8a862e35
268000 000000000000000048974ba0669938f7f8463650cd5c48c027aafd88c00a46af
270000 0000000000000002a775aec59dc6a9e4bb1c025cf1b8c2195dd9dc3998c827c5
272000 00000000000000050a89e2ffb28757d35e14615f23b981eca68906c8c71f65f2
274000 0000000000000003fe2d3425e9f9b906f02f40b3db90d908ba0fbd1e44cf43f8
276000 0000000000000004b8ed801f8a09ba8c1248a5b1dd1533a35124a80438573f59
278000 0000000000000001bcadd1e4b4d01063a17347dfca126c63893d2aa37d82eb7f
280000 0000000000000001c091ada69f444dc0282ecaabe4808ddbb2532e5555db0c03
282000 0000000000000002337ad25e6a9767420766309cfea79f13dd9c910bcf5ca063
284000 0000000000000000eac86582f121e5431734e2ea36bf73347022c99c1adae37f
286000 00000000000000004388ae444347bde423f2f3aa6ef335b50909f5bc27d31ea3
288000 00000000000000003c395f08779c3ac1301488b8a18c0999c008129a55610785
290000 0000000000000000fa0b2badd05db0178623ebf8dd081fe7eb874c26e27d0b3b
292000 0000000000000000620671231acb6a68134a0396235dcb0e53f4fc82bbaa1184
294000 0000000000000000cb2540b3f00ce422887904c75b24bf75b8a73817302a4138
296000 00000000000000009570102278e59ecf045c16ec8c8a5ea85bf823d0ec72e3d0
298000 000000000000000047d2f2eb7278e3f4aded9acaf502f5ec27bab5018b5871f2
300000 000000000000000082ccf8f1557c5d40b21edabb18d2d691cfbf87118bac7254
302000 0000000000000000072268c9bb18603566ed5012378c29bb4d37e34cead7448d
304000 00000000000000003558a1ceec3f5338c0e887b4171410195a7fa0a81bcaa628
306000 00000000000000002bb3265a8bf67ec2aa436c297ac7e56fcedd4dbaecccacc0
308000 00000000000000001d55aa114bddd81938d09e2dccd432dec59a4078ca0bc0f4
310000 0000000000000000125a28cc9e9209ddb75718f599a8039f6c9e7d9f1fb021e0
312000 00000000000000002bd1fa27964e31fe9861b40940e7ece2cfa359765b219a49
314000 000000000000000008ae6cb20997f3c4aacc50ee2f0d08a0c3691907fe7357a3
316000 00000000000000000d77a89ab1069e47d1213ae509de95ee0d9ab095a725f7d7
318000 00000000000000002583a647dc5f084a312e12bb90a70c3fe1eb1e4d419f35b6
320000 000000000000000015aab005b28a326ade60f07515c33517ea5cb598f28fb7ea
322000 0000000000000000177da809382f93ca1c4336811e4a910050689d317d62264e
324000 00000000000000000b9880c40075d763b2a5f04fc01444a6278c5d2d442cda0b
326000 00000000000000001e95e7216072cd53353b964054b592f7ce84d3743aab125a
328000 000000000000000009cb9a303d105e7b96b36546a3196f6f79ece4b43712cbb2
330000 00000000000000000faabab19f17c0178c754dbed023e6c871dcaf74159c5f02
332000 00000000000000001799255bc0c35f91f7d4fddfbf7e84dedf94fc59cde9b7f2
334000 000000000000000008d1ff7b7673837e9d7e1324dc7ab8498405ea583f43f53d
336000 0000000000000000125e3e6f327edcd7163b486efc16e79b8a996270127b54df
338000 00000000000000001983dc4a87df627b63cdce28e5321cb867fbbb74c0e87e8e
340000 00000000000000000d9b2508615d569e18f00c034d71474fc44a43af8d4a5003
342000 0000000000000000007220892af98a563a1c891c756e94be3f14edddcf637c3e
344000 000000000000000005f0a16f5a9f95eeb95c5eed0eb221e8f5dc5a9943a03aee
346000 0000000000000000068d33fd865621cb7eedbf05c6b235191fa1cb8ee2c797d7
348000 00000000000000001598a651988bb3a45237c4f801cf8049be20f74aed8e827a
350000 0000000000000000053cf64f0400bb38e0c4b3872c38795ddde27acb40a112bb
352000 00000000000000001635a4b5f27d2ec458f7bca550d71f490b93e98e7a07cbca
354000 00000000000000000cf8af9be2709e9d7adf2c33b3789aeeff517987f4be22e8
356000 0000000000000000138ce5493b612b0e90b66e2a76714088d6b3e6a4770215af
358000 0000000000000000073aceefab8c381c3c4edb4f87a6d5d2ae32184278218429
360000 00000000000000000ca6e07cf681390ff888b7f96790286a440da0f2b87c8ea6
362000 00000000000000000bfcad6c331dd152cfc713e9e0790978a10e0bfda3e030d5
364000 00000000000000000e20bcf213a0bbd6be88d5fede6b060c737f7f8b7f1df504
366000 0000000000000000138e108e780fdb71eb4cad533b46445ab6befbf9687f561f
368000 00000000000000000d39970aac12754eb89c2dcfda539b65562e5c3fec102c24
370000 000000000000000002cad3026f68357229dd6eaa6bcef6fe5166e1e53b039b8c
372000 0000000000000000028093cc8035a6bc4e0d1b40932c2f8b50312a3fc86bf3da
374000 00000000000000001016aa3783721673bebbcd1efa49946b52cceb09a81465a6
376000 0000000000000000106e9e99cf4fce4e8a4abc97f3e883956e26d76b3a1133ce
378000 00000000000000000516cd5b5f4b7e528d6e61c643595cc818f1d02f53da4281
380000 00000000000000000b06cee3cee10d2617e2024a996f5c613f7d786b15a571ff
382000 000000000000000003cf98590769bde40ffcd6800733ab47dd406d8203e65a89
384000 000000000000000005dc7ea53e2f6eeb09798cc9d2214f09d249661c36c288b3
386000 00000000000000000d94c8c0b0ddec874d2a597e988154733d9ea614292c08bb

137
agents/BTC_peers.txt

@ -1,137 +0,0 @@
108.58.252.82
74.207.233.193
130.211.146.81
71.193.19.234
173.66.1.180
104.158.113.201
108.207.245.69
107.4.134.66
96.231.100.124
209.6.208.31
69.141.89.74
82.20.129.167
5.9.222.226
149.210.234.41
168.235.85.242
52.91.247.30
191.237.64.28
173.236.101.34
73.189.2.240
106.186.113.184
173.64.13.6
73.166.27.56
70.106.255.189
168.62.188.213
71.234.225.255
24.41.10.204
72.175.146.90
184.107.155.82
162.220.47.150
12.23.127.150
169.228.66.43
192.227.137.5
71.205.232.181
207.182.151.130
46.4.22.45
198.50.238.171
174.59.182.120
66.172.10.4
75.73.82.209
91.121.108.61
24.6.74.4
37.187.78.27
96.32.46.235
107.170.13.184
148.251.151.48
178.62.70.16
144.76.185.151
144.76.92.199
91.121.210.159
76.105.242.7
54.84.231.113
89.187.134.220
64.15.77.36
212.51.147.153
216.15.33.203
74.100.90.30
185.18.6.3
104.131.65.197
89.248.174.54
128.8.124.7
54.232.245.146
67.205.101.120
72.207.119.149
192.95.27.144
69.61.93.240
209.91.190.202
50.35.82.152
66.175.220.212
23.239.22.219
73.229.104.201
207.244.73.8
78.129.251.170
139.162.211.181
172.245.5.156
98.144.123.251
177.238.90.180
198.71.92.236
73.254.38.48
75.189.201.141
52.24.104.64
71.231.209.66
87.224.35.189
73.162.143.196
82.204.103.94
91.148.210.17
94.242.229.158
188.121.252.243
70.39.8.97
95.97.112.190
109.228.152.9
91.209.77.101
217.76.121.251
79.136.29.43
178.212.136.92
178.255.41.123
84.212.200.24
91.145.49.56
162.220.246.101
95.167.109.125
153.163.32.61
78.67.29.111
92.247.229.163
210.195.201.103
95.84.162.95
106.38.234.67
186.88.0.18
121.208.106.80
120.55.193.136
124.171.128.201
54.94.163.92
98.217.125.225
104.156.97.121
162.255.117.230
129.13.252.36
79.120.12.63
108.5.176.30
69.144.244.229
76.22.18.34
115.29.186.22
78.46.193.75
213.91.211.17
164.177.179.162
134.249.141.40
69.140.88.12
178.212.136.108
109.120.250.3
154.127.61.55
123.120.167.101
73.210.74.120
82.136.95.220
124.122.212.150
81.191.80.160
96.58.196.51
77.23.111.25
14.175.245.51
76.164.234.12
92.156.214.192

93
crypto777/curve25519.c

@ -872,7 +872,7 @@ inline bits320 force_inline crecip(const bits320 z)
/* 2^255 - 21 */ return(fmul(t0, a));
}
void randombytes(unsigned char *x,long xlen);
void OS_randombytes(unsigned char *x,long xlen);
bits256 rand256(int32_t privkeyflag)
{
@ -1692,4 +1692,95 @@ uint64_t conv_NXTpassword(unsigned char *mysecret,unsigned char *mypublic,uint8_
memcpy(&addr,hash,sizeof(addr));
return(addr);
}
#include <stdio.h>
bits256 GENESIS_PUBKEY,GENESIS_PRIVKEY;
bits256 acct777_pubkey(bits256 privkey)
{
static uint8_t basepoint[32] = {9};
bits256 pubkey;
privkey.bytes[0] &= 248, privkey.bytes[31] &= 127, privkey.bytes[31] |= 64;
curve25519_donna(pubkey.bytes,privkey.bytes,basepoint);
return(pubkey);
}
uint64_t acct777_nxt64bits(bits256 pubkey)
{
bits256 acct;
vcalc_sha256(0,acct.bytes,pubkey.bytes,sizeof(pubkey));
return(acct.txid);
}
bits256 acct777_hashiter(bits256 privkey,bits256 pubkey,int32_t lockdays,uint8_t chainlen)
{
uint16_t lockseed,signlen = 0; uint8_t signbuf[16]; bits256 shared,lockhash;
lockseed = (chainlen & 0x7f) | (lockdays << 7);
signlen = 0, signbuf[signlen++] = lockseed & 0xff, signbuf[signlen++] = (lockseed >> 8) & 0xff;
privkey.bytes[0] &= 248, privkey.bytes[31] &= 127, privkey.bytes[31] |= 64;
shared = curve25519(privkey,pubkey);
vcalc_sha256cat(lockhash.bytes,shared.bytes,sizeof(shared),signbuf,signlen);
return(lockhash);
}
bits256 acct777_lockhash(bits256 pubkey,int32_t lockdays,uint8_t chainlen)
{
bits256 lockhash = GENESIS_PRIVKEY;
while ( chainlen > 0 )
lockhash = acct777_hashiter(lockhash,pubkey,lockdays,chainlen--);
return(lockhash);
}
bits256 acct777_invoicehash(bits256 *invoicehash,uint16_t lockdays,uint8_t chainlen)
{
int32_t i; bits256 lockhash,privkey;
OS_randombytes(privkey.bytes,sizeof(privkey)); // both privkey and pubkey are sensitive. pubkey allows verification, privkey proves owner
lockhash = privkey;
for (i=0; i<chainlen; i++)
lockhash = acct777_hashiter(lockhash,GENESIS_PUBKEY,chainlen - i,lockdays);
*invoicehash = lockhash;
return(privkey);
}
uint64_t acct777_sign(struct acct777_sig *sig,bits256 privkey,bits256 otherpubkey,uint32_t timestamp,uint8_t *data,int32_t datalen)
{
int32_t i; bits256 shared; uint8_t buf[sizeof(shared) + sizeof(timestamp)]; uint32_t t = timestamp;
for (i=0; i<sizeof(t); i++,t>>=8)
buf[i] = (t & 0xff);
sig->timestamp = timestamp;
shared = curve25519(privkey,otherpubkey);
memcpy(&buf[sizeof(timestamp)],shared.bytes,sizeof(shared));
vcalc_sha256cat(sig->sigbits.bytes,buf,sizeof(buf),data,datalen);
sig->pubkey = acct777_pubkey(privkey), sig->signer64bits = acct777_nxt64bits(sig->pubkey);
//printf(" calcsig.%llx pubkey.%llx signer.%llu | t%u crc.%08x len.%d shared.%llx <- %llx * %llx\n",(long long)sig->sigbits.txid,(long long)sig->pubkey.txid,(long long)sig->signer64bits,timestamp,_crc32(0,data,datalen),datalen,(long long)shared.txid,(long long)privkey.txid,(long long)otherpubkey.txid);
return(sig->signer64bits);
}
uint64_t acct777_validate(struct acct777_sig *sig,uint32_t timestamp,uint8_t *data,int32_t datalen)
{
struct acct777_sig checksig;
acct777_sign(&checksig,GENESIS_PRIVKEY,sig->pubkey,timestamp,data,datalen);
if ( memcmp(checksig.sigbits.bytes,sig->sigbits.bytes,sizeof(checksig.sigbits)) != 0 )
{
printf("sig compare error using sig->pub from %llu\n",(long long)acct777_nxt64bits(sig->pubkey));
return(0);
}
return(acct777_nxt64bits(sig->pubkey));
}
uint64_t acct777_signtx(struct acct777_sig *sig,bits256 privkey,uint32_t timestamp,uint8_t *data,int32_t datalen)
{
return(acct777_sign(sig,privkey,GENESIS_PUBKEY,timestamp,data,datalen));
}
uint64_t acct777_swaptx(bits256 privkey,struct acct777_sig *sig,uint32_t timestamp,uint8_t *data,int32_t datalen)
{
uint64_t othernxt;
if ( (othernxt= acct777_validate(sig,timestamp,data,datalen)) != sig->signer64bits )
return(0);
return(acct777_sign(sig,privkey,GENESIS_PUBKEY,timestamp,data,datalen));
}
#undef force_inline

3
crypto777/iguana_OS.c

@ -828,6 +828,9 @@ void *OS_tmpalloc(char *dirname,char *name,struct OS_memspace *mem,long origsize
void OS_init()
{
extern bits256 GENESIS_PUBKEY,GENESIS_PRIVKEY;
decode_hex(GENESIS_PUBKEY.bytes,sizeof(GENESIS_PUBKEY),GENESIS_PUBKEYSTR);
decode_hex(GENESIS_PRIVKEY.bytes,sizeof(GENESIS_PRIVKEY),GENESIS_PRIVKEYSTR);
SaM_PrepareIndices();
return(OS_portable_init());
}

465
iguana/SuperNET.c

@ -0,0 +1,465 @@
/******************************************************************************
* Copyright © 2014-2015 The SuperNET Developers. *
* *
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
* the top-level directory of this distribution for the individual copyright *
* holder information and the developer policies on copyright and licensing. *
* *
* Unless otherwise agreed in a custom licensing agreement, no part of the *
* SuperNET software, including this file may be copied, modified, propagated *
* or distributed except according to the terms contained in the LICENSE file *
* *
* Removal or modification of this copyright notice is prohibited. *
* *
******************************************************************************/
#ifndef MINIGUANA
#include "../crypto777/OS_portable.h"
#include "SuperNET.h"
int32_t nn_typelist[] = { NN_REP, NN_REQ, NN_RESPONDENT, NN_SURVEYOR, NN_PUB, NN_SUB, NN_PULL, NN_PUSH, NN_BUS, NN_PAIR };
char *nn_transports[] = { "tcp", "ws", "ipc", "inproc", "tcpmux", "", "", "" };
int32_t SuperNET_msglen(struct supernet_msghdr *msg)
{
return(msg->serlen[0] + ((int32_t)msg->serlen[1] << 8) + ((int32_t)msg->serlen[2] << 16));
}
int32_t SuperNET_msgvalidate(struct supernet_info *myinfo,struct supernet_msghdr *msg)
{
int32_t msglen = 0;
msglen = SuperNET_msglen(msg);
return(msglen);
}
struct supernet_msghdr *SuperNET_msgcreate(struct supernet_info *myinfo,struct supernet_info *dest,uint8_t type,uint8_t *buf,int32_t maxlen,uint8_t *data,long datalen,uint32_t duration)
{
uint32_t i,timestamp; struct supernet_msghdr *msg = 0;
if ( (datalen + sizeof(*msg)) < maxlen )
{
msg = (struct supernet_msghdr *)buf;
memset(msg,0,sizeof(*msg));
memcpy(msg->data,data,datalen);
msg->type = type;
timestamp = (uint32_t)time(NULL);
for (i=0; i<3; i++)
msg->serlen[i] = datalen & 0xff, datalen >>= 8;
for (i=0; i<4; i++)
msg->ser_timestamp[i] = timestamp & 0xff, timestamp >>= 8;
for (i=0; i<4; i++)
msg->ser_duration[i] = duration & 0xff, duration >>= 8;
// add sig here
}
return(msg);
}
void expand_epbits(char *endpoint,struct endpoint epbits)
{
char ipaddr[64];
if ( epbits.ipbits != 0 )
expand_ipbits(ipaddr,epbits.ipbits);
else strcpy(ipaddr,"*");
sprintf(endpoint,"%s://%s:%d",nn_transports[epbits.transport],ipaddr,epbits.port);
}
struct endpoint calc_epbits(char *transport,uint32_t ipbits,uint16_t port,int32_t type)
{
int32_t i; struct endpoint epbits;
memset(&epbits,0,sizeof(epbits));
for (i=0; i<(int32_t)(sizeof(nn_transports)/sizeof(*nn_transports)); i++)
if ( strcmp(transport,nn_transports[i]) == 0 )
{
epbits.ipbits = ipbits;
epbits.port = port;
epbits.transport = i;
epbits.nn = type;
break;
}
return(epbits);
}
int32_t ismyaddress(struct supernet_info *myinfo,char *server)
{
uint32_t ipbits; int32_t i,tlen; char str[64];
for (i=0; i<sizeof(nn_transports)/sizeof(*nn_transports); i++)
{
if ( nn_transports[i] == 0 )
break;
sprintf(str,"%s://",nn_transports[i]);
tlen = (int32_t)strlen(str);
if ( strncmp(server,str,tlen) == 0 )
{
server += tlen;
break;
}
}
if ( (ipbits= is_ipaddr(server)) != 0 )
{
if ( strcmp(server,myinfo->ipaddr) == 0 || myinfo->ipbits == ipbits )
{
printf("(%s) MATCHES me (%s)\n",server,myinfo->ipaddr);
return(1);
}
}
else if ( myinfo->my64bits == ipbits )
return(1);
//printf("(%s) is not me (%s)\n",server,myipaddr);
return(0);
}
char *nn_typestr(int32_t type)
{
switch ( type )
{
// Messages that need a response from the set of peers: SURVEY
case NN_SURVEYOR: return("NN_SURVEYOR"); break;
case NN_RESPONDENT: return("NN_RESPONDENT"); break;
// Messages that need a response, but only from one peer: REQ/REP
case NN_REQ: return("NN_REQ"); break;
case NN_REP: return("NN_REP"); break;
// One-way messages to one peer: PUSH/PULL
case NN_PUSH: return("NN_PUSH"); break;
case NN_PULL: return("NN_PULL"); break;
// One-way messages to all: PUB/SUB
case NN_PUB: return("NN_PUB"); break;
case NN_SUB: return("NN_SUB"); break;
case NN_BUS: return("NN_BUS"); break;
case NN_PAIR: return("NN_PAIR"); break;
}
return("NN_ERROR");
}
int32_t nn_oppotype(int32_t type)
{
switch ( type )
{
// Messages that need a response from the set of peers: SURVEY
case NN_SURVEYOR: return(NN_RESPONDENT); break;
case NN_RESPONDENT: return(NN_SURVEYOR); break;
// Messages that need a response, but only from one peer: REQ/REP
case NN_REQ: return(NN_REP); break;
case NN_REP: return(NN_REQ); break;
// One-way messages to one peer: PUSH/PULL
case NN_PUSH: return(NN_PULL); break;
case NN_PULL: return(NN_PUSH); break;
// One-way messages to all: PUB/SUB
case NN_PUB: return(NN_SUB); break;
case NN_SUB: return(NN_PUB); break;
case NN_BUS: return(NN_BUS); break;
case NN_PAIR: return(NN_PAIR); break;
}
return(-1);
}
int32_t nn_portoffset(int32_t type)
{
int32_t i;
for (i=0; i<(int32_t)(sizeof(nn_typelist)/sizeof(*nn_typelist)); i++)
if ( nn_typelist[i] == type )
return(i + 2);
return(-1);
}
int32_t nn_socket_status(int32_t nnsock,int32_t timeoutmillis)
{
struct nn_pollfd pfd;
int32_t rc;
pfd.fd = nnsock;
pfd.events = NN_POLLIN | NN_POLLOUT;
if ( (rc= nn_poll(&pfd,1,timeoutmillis)) == 0 )
return(pfd.revents);
else return(-1);
}
int32_t nn_settimeouts(int32_t sock,int32_t sendtimeout,int32_t recvtimeout)
{
int32_t retrymillis,maxmillis;
if ( (maxmillis= SUPERNET_NETWORKTIMEOUT) == 0 )
maxmillis = 3000;
retrymillis = maxmillis/40;
if ( nn_setsockopt(sock,NN_SOL_SOCKET,NN_RECONNECT_IVL,&retrymillis,sizeof(retrymillis)) < 0 )
fprintf(stderr,"error setting NN_REQ NN_RECONNECT_IVL_MAX socket %s\n",nn_errstr());
else if ( nn_setsockopt(sock,NN_SOL_SOCKET,NN_RECONNECT_IVL_MAX,&maxmillis,sizeof(maxmillis)) < 0 )
fprintf(stderr,"error setting NN_REQ NN_RECONNECT_IVL_MAX socket %s\n",nn_errstr());
else if ( sendtimeout > 0 && nn_setsockopt(sock,NN_SOL_SOCKET,NN_SNDTIMEO,&sendtimeout,sizeof(sendtimeout)) < 0 )
fprintf(stderr,"error setting sendtimeout %s\n",nn_errstr());
else if ( recvtimeout > 0 && nn_setsockopt(sock,NN_SOL_SOCKET,NN_RCVTIMEO,&recvtimeout,sizeof(recvtimeout)) < 0 )
fprintf(stderr,"error setting sendtimeout %s\n",nn_errstr());
else return(0);
return(-1);
}
int32_t nn_createsocket(struct supernet_info *myinfo,char *endpoint,int32_t bindflag,char *name,int32_t type,uint16_t port,int32_t sendtimeout,int32_t recvtimeout)
{
int32_t sock;
if ( (sock= nn_socket(AF_SP,type)) < 0 )
fprintf(stderr,"error getting socket %s\n",nn_errstr());
if ( bindflag != 0 )
{
if ( endpoint[0] == 0 )
expand_epbits(endpoint,calc_epbits(myinfo->transport,0,port,type));
if ( nn_bind(sock,endpoint) < 0 )
fprintf(stderr,"error binding to relaypoint sock.%d type.%d to (%s) (%s) %s\n",sock,type,name,endpoint,nn_errstr());
else fprintf(stderr,"BIND.(%s) <- %s\n",endpoint,name);
}
else if ( bindflag == 0 && endpoint != 0 && endpoint[0] != 0 )
{
if ( nn_connect(sock,endpoint) < 0 )
fprintf(stderr,"error connecting to relaypoint sock.%d type.%d to (%s) (%s) %s\n",sock,type,name,endpoint,nn_errstr());
else fprintf(stderr,"%s -> CONNECT.(%s)\n",name,endpoint);
}
if ( nn_settimeouts(sock,sendtimeout,recvtimeout) < 0 )
{
fprintf(stderr,"nn_createsocket.(%s) %d\n",name,sock);
return(-1);
}
return(sock);
}
bits256 SuperNET_OPRETURN(struct supernet_info *myinfo,char *symbol,double fee,uint8_t *buf,int32_t len)
{
bits256 txid;
printf("send OPRETURN\n");
return(txid);
}
bits256 SuperNET_agentannounce(struct supernet_info *myinfo,struct supernet_agent *agent,cJSON *network)
{
static bits256 zero;
uint8_t buf[80 + sizeof(struct iguana_msghdr)],*data;
bits256 pubkey,sig; int32_t i,len=0; uint8_t netmagic[4]; char *sigstr,*announce,*pubkeystr;
memset(buf,0,sizeof(buf));
data = &buf[sizeof(struct iguana_msghdr)];
if ( (announce= jstr(network,"announce")) != 0 )
{
data[len++] = SCRIPT_OPRETURN;
data[len++] = 75;
iguana_rwnum(1,&data[len],sizeof(myinfo->ipbits),&myinfo->ipbits);
for (i=0; i<7; i++)
if ( (data[len+i]= announce[i]) == 0 )
break;
len = 13;
if ( (pubkeystr= jstr(network,"pubkey")) == 0 || strlen(pubkeystr) != sizeof(bits256)*2 )
pubkeystr = GENESIS_PUBKEYSTR;
decode_hex(pubkey.bytes,sizeof(pubkey),pubkeystr);
len += iguana_rwbignum(1,&data[len],sizeof(pubkey),pubkey.bytes); // 45 bytes
if ( (sigstr= jstr(network,"sig")) != 0 && strlen(sigstr) == sizeof(bits256)*2 )
{
sigstr = GENESIS_PUBKEYSTR;
len += iguana_rwbignum(1,&data[len],sizeof(sig),sig.bytes); // 77 bytes
}
decode_hex(netmagic,4,"e4c2d8e6");
iguana_sethdr((struct iguana_msghdr *)buf,netmagic,"SuperNET",data,len);
return(SuperNET_OPRETURN(myinfo,"BTCD",.001,buf,len));
}
printf("invalid SuperNET OPRETURN protocol.(%s)\n",announce!=0?announce:"");
return(zero);
}
void Supernet_networkadd(struct supernet_info *myinfo,struct supernet_agent *agent,cJSON *network)
{
int32_t sendtimeout=0,recvtimeout=0;
agent->pubpoint[0] = agent->reppoint[0] = 0;
if ( (agent->pubport= juint(network,"pubport")) > 1000 )
{
agent->pubsock = nn_createsocket(myinfo,agent->pubpoint,1,"NN_PUB",NN_PUB,agent->pubport,sendtimeout,recvtimeout);
SuperNET_agentannounce(myinfo,agent,network);
}
else agent->pubport = -1;
if ( (agent->repport= juint(network,"LBport")) > 1000 )
agent->repsock = nn_createsocket(myinfo,agent->reppoint,1,"NN_REP",NN_REP,agent->repport,sendtimeout,recvtimeout);
else agent->repport = -1;
agent->subsock = nn_createsocket(myinfo,0,0,"NN_SUB",NN_SUB,0,sendtimeout,recvtimeout);
nn_setsockopt(agent->subsock,NN_SUB,NN_SUB_SUBSCRIBE,"",0);
agent->reqsock = nn_createsocket(myinfo,0,0,"NN_REQ",NN_REQ,0,sendtimeout,recvtimeout);
}
int32_t SuperNET_agentcommand(struct supernet_info *myinfo,struct supernet_agent *agent,struct supernet_msghdr *H,uint8_t *buf,int32_t buflen)
{
char *name; cJSON *json; int32_t i;
if ( strcmp(H->command,"register") == 0 )
{
if ( (json= cJSON_Parse((char *)buf)) != 0 )
{
if ( (name= jstr(json,"name")) != 0 )
{
memset(agent->name,0,sizeof(agent->name));
strncpy(agent->name,name,sizeof(agent->name)-1);
if ( (agent->networks= jarray(&agent->num,json,"networks")) != 0 )
{
for (i=0; i<agent->num; i++)
Supernet_networkadd(myinfo,agent,jitem(agent->networks,i));
}
} else free_json(json);
}
}
return(0);
}
int32_t nn_add_LBendpoints(struct supernet_info *myinfo,uint16_t LBport,uint16_t PUBport,int32_t reqsock,int32_t subsock,int32_t priority,char endpoints[][MAX_SERVERNAME],int32_t num)
{
int32_t i; char endpoint[512]; struct endpoint epbits; uint32_t ipbits;
if ( num > 0 && endpoints != 0 && nn_setsockopt(reqsock,NN_SOL_SOCKET,NN_SNDPRIO,&priority,sizeof(priority)) >= 0 )
{
for (i=0; i<num; i++)
{
if ( (ipbits= (uint32_t)calc_ipbits(endpoints[i])) == 0 )
{
printf("null ipbits.(%s)\n",endpoints[i]);
continue;
}
//printf("epbits.%llx ipbits.%x %s\n",*(long long *)&epbits,(uint32_t)ipbits,endpoint);
if ( ismyaddress(myinfo,endpoints[i]) == 0 )
{
epbits = calc_epbits("tcp",ipbits,LBport,NN_REP), expand_epbits(endpoint,epbits);
if ( reqsock >= 0 && nn_connect(reqsock,endpoint) >= 0 )
printf("+R%s ",endpoint);
epbits = calc_epbits("tcp",ipbits,PUBport,NN_PUB), expand_epbits(endpoint,epbits);
if ( subsock >= 0 && nn_connect(subsock,endpoint) >= 0 )
printf("+P%s ",endpoint);
}
}
printf("added priority.%d\n",priority);
priority++;
} else printf("error setting priority.%d (%s)\n",priority,nn_errstr());
return(priority);
}
int32_t _req_socket(struct supernet_info *myinfo,uint16_t LBport,uint16_t PUBport,int32_t subsock,int32_t maxmillis,char endpoints[][MAX_SERVERNAME],int32_t num,char backups[][MAX_SERVERNAME],int32_t numbacks,char failsafes[][MAX_SERVERNAME],int32_t numfailsafes)
{
int32_t reqsock,timeout,retrymillis,priority = 1;
if ( (reqsock= nn_socket(AF_SP,NN_REQ)) >= 0 )
{
retrymillis = (maxmillis / 30) + 1;
printf("!!!!!!!!!!!! reqsock.%d !!!!!!!!!!!\n",reqsock);
if ( nn_setsockopt(reqsock,NN_SOL_SOCKET,NN_RECONNECT_IVL,&retrymillis,sizeof(retrymillis)) < 0 )
printf("error setting NN_REQ NN_RECONNECT_IVL_MAX socket %s\n",nn_errstr());
else if ( nn_setsockopt(reqsock,NN_SOL_SOCKET,NN_RECONNECT_IVL_MAX,&maxmillis,sizeof(maxmillis)) < 0 )
fprintf(stderr,"error setting NN_REQ NN_RECONNECT_IVL_MAX socket %s\n",nn_errstr());
if ( (timeout= myinfo->networktimeout) == 0 )
myinfo->networktimeout = 10000;
if ( 1 && nn_setsockopt(reqsock,NN_SOL_SOCKET,NN_RCVTIMEO,&timeout,sizeof(timeout)) < 0 )
printf("error setting NN_SOL_SOCKET NN_RCVTIMEO socket %s\n",nn_errstr());
timeout = 100;
if ( 1 && nn_setsockopt(reqsock,NN_SOL_SOCKET,NN_SNDTIMEO,&timeout,sizeof(timeout)) < 0 )
printf("error setting NN_SOL_SOCKET NN_SNDTIMEO socket %s\n",nn_errstr());
if ( num > 0 )
priority = nn_add_LBendpoints(myinfo,LBport,PUBport,reqsock,subsock,priority,endpoints,num);
if ( numbacks > 0 )
priority = nn_add_LBendpoints(myinfo,LBport,PUBport,reqsock,subsock,priority,backups,numbacks);
if ( numfailsafes > 0 )
priority = nn_add_LBendpoints(myinfo,LBport,PUBport,reqsock,subsock,priority,failsafes,numfailsafes);
} else printf("error getting req socket %s\n",nn_errstr());
//printf("RELAYS.lb.num %d\n",RELAYS.lb.num);
return(reqsock);
}
int32_t badass_servers(char servers[][MAX_SERVERNAME],int32_t max)
{
int32_t n = 0;
strcpy(servers[n++],"89.248.160.237");
strcpy(servers[n++],"89.248.160.238");
strcpy(servers[n++],"89.248.160.239");
strcpy(servers[n++],"89.248.160.240");
strcpy(servers[n++],"89.248.160.241");
strcpy(servers[n++],"89.248.160.242");
strcpy(servers[n++],"89.248.160.243");
strcpy(servers[n++],"89.248.160.244");
strcpy(servers[n++],"89.248.160.245");
return(n);
}
int32_t crackfoo_servers(char servers[][MAX_SERVERNAME],int32_t max)
{
int32_t n = 0;
if ( 0 )
{
strcpy(servers[n++],"167.114.96.223");
strcpy(servers[n++],"167.114.113.25");
strcpy(servers[n++],"167.114.113.27");
strcpy(servers[n++],"167.114.113.194");
strcpy(servers[n++],"167.114.113.197");
strcpy(servers[n++],"167.114.113.201");
strcpy(servers[n++],"167.114.113.246");
strcpy(servers[n++],"167.114.113.249");
strcpy(servers[n++],"167.114.113.250");
strcpy(servers[n++],"192.99.151.160");
strcpy(servers[n++],"167.114.96.222");
}
return(n);
}
int32_t nn_reqsocket(struct supernet_info *myinfo,uint16_t LBport,uint16_t PUBport,int32_t subsock,int32_t maxmillis)
{
char Cservers[32][MAX_SERVERNAME],Bservers[32][MAX_SERVERNAME],failsafes[4][MAX_SERVERNAME];
int32_t n,m,reqsock,numfailsafes = 0;
strcpy(failsafes[numfailsafes++],"5.9.102.210");
n = crackfoo_servers(Cservers,sizeof(Cservers)/sizeof(*Cservers));
m = badass_servers(Bservers,sizeof(Bservers)/sizeof(*Bservers));
reqsock = _req_socket(myinfo,LBport,PUBport,subsock,maxmillis,Bservers,m,Cservers,n,failsafes,numfailsafes);
return(reqsock);
}
void SuperNET_announce(struct supernet_info *myinfo,char *servicename)
{
struct supernet_msghdr *msg; uint8_t buf[512]; char jsonstr[512],str[65]; long len; uint64_t r;
OS_randombytes((uint8_t *)&r,sizeof(r));
sprintf(jsonstr,"{\"agent\":\"SuperNET\",\"method\":\"announce\",\"servicepub\":\"%s\",\"service\":\"%s\",\"tag\":\"%llu\"}",bits256_str(str,myinfo->myaddr.pubkey),servicename,r);
len = strlen(jsonstr)+1;
if ( (msg= SuperNET_msgcreate(myinfo,0,0,buf,sizeof(buf),(uint8_t *)jsonstr,len,0)) != 0 )
{
nn_send(myinfo->reqsock,jsonstr,len,0);
}
}
void SuperNET_recv(struct supernet_info *myinfo,int32_t insock,int32_t outsock)
{
int32_t recvlen,datalen; struct supernet_msghdr *msg;
if ( myinfo->recvbuf == 0 )
myinfo->recvbuf = calloc(1,SUPERNET_MAXRECVBUF);
if ( (recvlen= nn_recv(insock,myinfo->recvbuf,SUPERNET_MAXRECVBUF,0)) > 0 )
{
msg = (void *)myinfo->recvbuf;
if ( (datalen= SuperNET_msgvalidate(myinfo,msg)) == 0 )
{
printf("superRECV.(%s) len.%d\n",msg->data,datalen);
}
}
}
void SuperNET_loop(void *args)
{
struct supernet_info *myinfo = args;
while ( 1 )
{
if ( (nn_socket_status(myinfo->LBsock,1) & POLLIN) != 0 )
SuperNET_recv(myinfo,myinfo->LBsock,myinfo->LBsock); // req
else if ( (nn_socket_status(myinfo->subsock,1) & POLLIN) != 0 )
SuperNET_recv(myinfo,myinfo->subsock,myinfo->PUBsock); // info update
else usleep(10000);
}
}
void SuperNET_init(struct supernet_info *myinfo,uint16_t PUBport,uint16_t LBport)
{
int32_t sendtimeout,recvtimeout;
sendtimeout = 100;
recvtimeout = 1000;
myinfo->PUBpoint[0] = myinfo->LBpoint[0] = 0;
if ( (myinfo->PUBport= PUBport) != 0 )
{
myinfo->PUBsock = nn_createsocket(myinfo,myinfo->PUBpoint,1,"NN_PUB",NN_PUB,myinfo->PUBport,sendtimeout,recvtimeout);
}
else myinfo->PUBport = -1;
if ( (myinfo->LBport= LBport) != 0 )
myinfo->LBsock = nn_createsocket(myinfo,myinfo->LBpoint,1,"NN_REP",NN_REP,myinfo->LBport,sendtimeout,recvtimeout);
else myinfo->LBport = -1;
myinfo->subsock = nn_createsocket(myinfo,0,0,"NN_SUB",NN_SUB,0,sendtimeout,recvtimeout);
nn_setsockopt(myinfo->subsock,NN_SUB,NN_SUB_SUBSCRIBE,"",0);
myinfo->reqsock = nn_reqsocket(myinfo,myinfo->LBport,myinfo->PUBport,myinfo->subsock,60000);
SuperNET_announce(myinfo,"ramchain");
}
#endif

19
iguana/SuperNET.h

@ -20,13 +20,15 @@
#include "../includes/cJSON.h"
#include "../includes/nanomsg/nn.h"
#define SUPERNET_PORT 7778
#define SUPERNET_PORT 7776
#define SUPERNET_NETWORKTIMEOUT 10000
#define SUPERNET_POLLTIMEOUT 1
#define SUPERNET_APIUSLEEP (SUPERNET_POLLTIMEOUT * 10000)
#define SUPERNET_MAXAGENTS 64
#define NXT_TOKEN_LEN 160
#define nn_errstr() nn_strerror(nn_errno())
#define MAX_SERVERNAME 128
#define SUPERNET_MAXRECVBUF (1024 * 1024 * 16)
/*#define LB_OFFSET 1
#define PUBGLOBALS_OFFSET 2
@ -46,7 +48,7 @@ struct endpoint { queue_t nnrecvQ; int32_t nnsock,nnind; uint64_t ipbits:32,port
struct direct_connection { char handler[16]; struct endpoint epbits; int32_t sock; };
struct supernet_msghdr { uint8_t type,serlen[3]; char command[16]; uint8_t hdrdata[44]; uint8_t data[]; };
struct supernet_msghdr { bits256 sig; uint8_t type,serlen[3],ser_nonce[4],ser_timestamp[4],ser_duration[4]; char command[16]; uint8_t data[]; };
struct supernet_agent
{
@ -57,13 +59,18 @@ struct supernet_agent
uint32_t ipbits,dead; int32_t num,sock; uint16_t port,pubport,repport;
};
struct supernet_address { bits256 pubkey; };
struct supernet_info
{
char ipaddr[64],transport[8]; int32_t APISLEEP; int32_t iamrelay; uint64_t my64bits; uint64_t ipbits;
int32_t Debuglevel,readyflag,dead,POLLTIMEOUT; char rpcsymbol[16];
int32_t Debuglevel,readyflag,dead,POLLTIMEOUT; char rpcsymbol[16],LBpoint[64],PUBpoint[64];
//int32_t pullsock,subclient,lbclient,lbserver,servicesock,pubglobal,pubrelays,numservers;
bits256 privkey,pubkey;
uint16_t port,serviceport,acceptport;
bits256 privkey;
uint8_t *recvbuf;
struct supernet_address myaddr;
int32_t LBsock,PUBsock,reqsock,subsock,networktimeout;
uint16_t LBport,PUBport,reqport,subport;
struct nn_pollfd pfd[SUPERNET_MAXAGENTS]; //struct relay_info active;
struct supernet_agent agents[SUPERNET_MAXAGENTS]; queue_t acceptQ; int32_t numagents;
};
@ -79,7 +86,7 @@ struct supernet_endpoint
void expand_epbits(char *endpoint,struct endpoint epbits);
struct endpoint calc_epbits(char *transport,uint32_t ipbits,uint16_t port,int32_t type);
void SuperNET_init();
void SuperNET_init(struct supernet_info *myinfo,uint16_t PUBport,uint16_t LBport);
char *SuperNET_JSON(struct supernet_info *myinfo,cJSON *json,char *remoteaddr);
char *pangea_parser(struct supernet_info *myinfo,char *method,cJSON *json,char *remoteaddr);

2
iguana/iguana.sources

@ -1 +1 @@
SOURCES := iguana_tx.c iguana_wallet.c iguana_html.c iguana_pubkeys.c iguana_recv.c iguana_bundles.c iguana_msg.c iguana_rpc.c iguana777.c iguana_chains.c iguana_peers.c iguana_accept.c iguana_bitmap.c iguana_init.c iguana_ramchain.c iguana_blocks.c iguana_json.c $(CRYPTO777_SRCS) main.c
SOURCES := SuperNET.c iguana_tx.c iguana_wallet.c iguana_html.c iguana_pubkeys.c iguana_recv.c iguana_bundles.c iguana_msg.c iguana_rpc.c iguana777.c iguana_chains.c iguana_peers.c iguana_accept.c iguana_bitmap.c iguana_init.c iguana_ramchain.c iguana_blocks.c iguana_json.c $(CRYPTO777_SRCS) main.c

3
iguana/main.c

@ -327,6 +327,9 @@ void iguana_main(void *arg)
}
if ( arg != 0 )
SuperNET_JSON(&MYINFO,cJSON_Parse(arg),0);
#ifndef MINIGUANA
SuperNET_init(&MYINFO,MYINFO.PUBport,MYINFO.LBport);
#endif
//init_InstantDEX();
while ( 1 )
{

4
includes/curve25519.h

@ -33,9 +33,13 @@ typedef union _bits384 bits384;
struct sha256_vstate { uint64_t length; uint32_t state[8],curlen; uint8_t buf[64]; };
struct rmd160_vstate { uint64_t length; uint8_t buf[64]; uint32_t curlen, state[5]; };
struct acct777_sig { bits256 sigbits,pubkey; uint64_t signer64bits; uint32_t timestamp; };
#undef force_inline
#define force_inline __attribute__((always_inline))
bits320 fmul(const bits320 in2,const bits320 in);
bits320 fexpand(bits256 basepoint);
bits256 fcontract(const bits320 input);

Loading…
Cancel
Save