/ NETWORKING
NETWORKING
  1  Networking
  2  ----------
  3  
  4  Part 0: Introduction
  5  --------------------
  6  There are various ways of achieving a network in arching-kaos and some of them
  7  are documented here. The ones that are missing, either their are under testing,
  8  considered to be covered or not yet grasped.
  9  
 10  Part 1: Preassumptions
 11  ----------------------
 12  This document assumes you somehow familiarized yourself with the scripts and
 13  their usage.
 14  
 15  Part 2: Networking via IPFS
 16  ---------------------------
 17  We need to mention here that when you install arching-kaos-tools, IPFS is also
 18  installed. Furthermore, a swarm key is downloaded and installed as well. This
 19  is used to connect to aknet swarm in IPFS. Hence, you 'll need some peers to
 20  connect to via IPFS. Ask for that in #arching-kaos over at IRC. See `SUPPORT`
 21  file as well.
 22  
 23  Other than that, you can make up yourself a swarm and express your creativity
 24  there.
 25  
 26  Part 3: Networking via Stellar Network
 27  --------------------------------------
 28  Stellar Network is used as a peering system. If you own an address in XLM, you
 29  can store a named variable in your address. You 'll be required to "lock" 0.5XLM
 30  to persist the value you want. You'll be also required to trust ARCHINGKAOS
 31  asset if you want your content to be retrievable via https://arching-kaos.net
 32  and contribute with your creativity there.
 33  
 34  3.1 Assumption
 35  --------------
 36  We assume you already have a Stellar wallet and you also have direct access to
 37  your private key. This will be needed in case you don't use some wallet,
 38  compatible with https://laboratory.stellar.org/ which we will be using for
 39  connecting our arching-kaos configuration link (aka AKID) with our Stellar
 40  address.
 41  
 42  3.2 Preparation
 43  ---------------
 44  Before we publish anything, we need to know what we need to publish and where.
 45  
 46  Issuing the command
 47  ```
 48  ak config --get-ipns-key
 49  ```
 50  will return to us the IPNS key that points to our current AKID.
 51  
 52  We will need this value for the next step
 53  
 54  3.3 Publishing IPNS key to Stellar network
 55  ------------------------------------------
 56  1. Visit https://laboratory.stellar.org/#?network=public and go to the "Build
 57  transaction" option,
 58  2. Enter your Stellar address in the Source Address field,
 59  3. Click the "Fetch next sequence number for account starting with ..." button,
 60  4. Scroll down to find the "Operation Type" and select from the dropdown menu
 61  the "Manage data" option,
 62  5. Use as "Entry name": "config" (without the double quotes),
 63  6. Paste the IPNS link we got from the previous section, in the "Entry value"
 64  field,
 65  7. Scroll further down and click the "Sign in Transaction Signer" button,
 66  8. Sign the transaction with your wallet or your private key,
 67  9. Submit the transaction to the Stellar Network!
 68  
 69  Congratulations! You successfully published your IPNS reference to your AKID in
 70  the Stellar Network.
 71  
 72  3.4 Open a trustline to ARCHINGKAOS
 73  -----------------------------------
 74  To be able to post content on arching-kaos.net you will need to trust the asset
 75  ARCHINGKAOS issued by GB4QVKD6NW3CSNO5TNPARAWNPPXOPSSTKB35XCWB7PUNBIQTK3DVELB2.
 76  
 77  Build a transaction as described above, but instead of "Manage data" select
 78  "ChangeTrust" option. Set the information above in the appropriate fields,
 79  sign the transaction and submit it.
 80  
 81  Now, your contributions will appear at https://arching-kaos.net 
 82  
 83  Part 4: Networking with CJDNS
 84  -----------------------------
 85  CJDNS is a decentralized mesh networking alternative to the internet. It uses
 86  the fc00::/8 private space of IPv6 protocol. Your IPv6 derives from your public
 87  key where its private part is used to decrypt your incoming packets.
 88  
 89  Using CJDNS and arching-kaos-tools to netwok around is pretty easy but there are
 90  steps to make it work as well. Of course, you will need CJDNS to be running in
 91  the machine you want to network with/from. Furthermore, you will also need the
 92  cjdns-tools, laying under the tools folder in the cjdns repository to be in your
 93  PATH.
 94  
 95  You then can use the `ak network -s cjdns` to find other akdaemon(s) running in
 96  your relative neighbourhood. `dumpLinks` is used to retrieve the nodes in this
 97  area. You can find more intense scanning scripts around like `walk.sh` by ircerr
 98  which is able to reach the whole public network of cjdns.
 99  
100  - http://hia.cjdns.ca/watchlist/c/walk.sh  (seq)
101  - http://hia.cjdns.ca/watchlist/c/walk2.sh (threaded)
102  
103  > TODO: We should be storing the output on a relevant file so it can be reached by
104  > the API as well or ask for current known nodes without rescanning the network.
105  
106  Part 5: Update on networking
107  ----------------------------
108  Great news everyone! `ak-network` is here:
109  ```
110  $ ak network
111  # ak-network - AK Nettool
112  # =======================
113  #
114  # Network tools
115  #
116  # Usage:
117  #
118  #    -h, --help                                           Prints this help message
119  #    -c, --connect [ipfs|cjdns]                           Connect to network(s)
120  #    -p, --peers [ipfs|cjdns|stellar|yggdrasil|incoming]  Outputs peers found
121  #    -s, --scan [ipfs|cjdns|stellar|yggdrasil|incoming]   Scan network(s) for peers
122  #
123  # Bonus: CJDNS network scanning modes
124  #
125  #    -s, --scan cjdns [-w|--whole]        Scan using HIA's knowledge
126  #    -s, --scan cjdns [-d|--dump]         Scan using CJDNS' dumpLinks (default)
127  ```
128  
129  Though:
130  ```
131  $ ak network --scan ipfs
132  20240707_065927 <ak-network> [ERROR] Not implemented: _ak_network_scan_ipfs
133  ```
134  
135  > TODO ^^ maybe
136  > Which I think I should not try to do since we use `ak-config` as the key on IPFS
137  > to publish our `node_info` at and we can not guess keys just in case we found
138  > one with `node_info`. A work around could be to use the `self` key and publish
139  > there instead of `ak-config`. Previously, since we were using for `IPFS_REPO`
140  > the default directory, it was thought that the `self` key could be already in
141  > use. Now that we do have our own dedicated path for `IPFS_REPO`, it could be
142  > revisited. But, as mentioned in other places, we are about to drop IPFS in the
143  > future. Whichever comes first?
144  
145  Part 6: Yggdrasil
146  -----------------
147  In the same way we do the full scan ( -w|--whole ) for cjdns network range, we
148  also do the same for Yggdrasil network. The preassumption here is that yggdrasil
149  is already installed and peered. We get some IP lists from scans from the YIA
150  service running by ircerr.
151  
152  Part 7: Incoming
153  ----------------
154  Incoming connections' IPs to the API are stored and can be scanned for the known
155  API port for peering purposes.