在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:SomajitDey/ipfs-chat开源软件地址:https://github.com/SomajitDey/ipfs-chat开源编程语言:Shell 100.0%开源软件介绍:IPFS-Chat
Keywords: p2p; distributed; server-less; broker-less; TUI; secure; texting; file-sharing; ipfs; pubsub; privacy Table of ContentsInstallationDownload:git clone --depth 1 --no-tags https://github.com/SomajitDey/ipfs-chat; cd ipfs-chat or, wget https://raw.githubusercontent.com/SomajitDey/ipfs-chat/main/ipfs-chat \
&& chmod +x ./ipfs-chat Install:sudo mv ./ipfs-chat /usr/local/bin Or, if you don't have sudo priviledge: mkdir -p ~/.bin; mv ./ipfs-chat ~/.bin; export PATH="${PATH}:${HOME}/.bin"
# Also put the last export command inside ${HOME}/.bashrc Do you want an auto-install feature, such as Usageipfs-chat -r <room> -n <nick> -d <dl dir> -D <max file MB> -c <repo> -o <log> -w|-l -e
ipfs-chat -g # Generating a random room name, for when your brain can't do it
ipfs-chat -v # Version
ipfs-chat -u <version>|<branch> # Update
ipfs-chat -h # Help All command-line options/flags are optional. Unobvious options are explained below.
Defaults:room: nick: download directory: max shared file size: -1 (i.e. unlimited) repo: chat log: N/A WAN + LAN Multiple-instances:Multiple instances of
SnapshotTestingYou can test ipfs-chat -W -b -c '/tmp/ipfs-chat' -n 'partner' # In one terminal
ipfs-chat -b # In another terminal
Depending on your internet speed, state of the public IPFS network (WAN-DHT) and durations for which other chatroom peers have been online, peer discovery may take a while (upto ~ 30 seconds according to my tests). Test further. Disconnect from the internet and run the above two instances on your local machine (or two LAN-connected hosts) with the Changing terminal window sizeShould you ever need to change the size of the terminal Peer discoveryName of the room is the shared secret. Every participant provides a (rendezvous) file at regular intervals whose content is a time-based nonce derived from the shared secret, viz. the room name. Along with this, participants publish their public (WAN) multiaddresses at a pubsub topic that is also derived from the room name. To join the chat network, viz. the room, one needs to connect to as many online participants as possible. This is done by first querying the DHT for the providers of the rendezvous file and then swarm connecting to those peer IDs. Participants also listen to the pubsub topic where the multiaddresses are published in order to discover peers they are not directly connected to. To accommodate for peers leaving and joining the room, the query and swarm connect steps are iterated at regular intervals. Peers behind NAT use autorelay or p2p-circuit to be accessible by others. Local (LAN based) discovery is also enabled (Discovery.MDNS.Enabled=true). Also, if a peer sees a message (over pubsub) from a peer that it is not directly connected to, it tries to connect to it immediately. IPNS over pubsub is also used to speed up peer discovery. Every chatroom peer resolves the same IPNS key(s) in order to subscribe to the same name-specific topics. Because of this, some peers are already connected when the peer discovery using DHT and pubsub are launched. During startup, the node tries to connect to the peers from the last session. For Note: The rendezvous nonce changes every 2 mins. Due to this, a peer might be shown to be online upto 2 mins after it goes offline. SecurityAuthenticity of the messages is established through IPNS over pubsub (See Messaging). All general messages are encrypted with a symmetric key (AES128) derived from the room name using a key-derivation-function (kdf) based on Argon2. All private messages are encrypted with a public key (ECDH/cv25519) belonging to the recipient. All shared files and directories are encrypted (See File sharing). The pubsub topics are separate keys derived from the room name. Therefore, the public network, that mediates the pubsub and passes the messages along, never knows the actual room name and hence, the encryption key. If the MessagingEvery peer publishes its nick and a self-signed PGP public key (primary-key EDDSA/ed25519 for signing + subkey ECDH/cv25519 for encryption) under its peer ID over IPNS at the start of every session. This authenticates its claim over the nick and the public key. After discovering a peer, other peers resolve its IPNS entry and caches its nick and pubkey for use throughout the session. For general messaging, a peer signs its message with its private key and encrypts with the aforementioned symmetric key derived from the room name. For private messaging, the message is encrypted with the recipient's public key instead. The whole encrypted object is encoded in base64 and published over pubsub along with the sender's peer ID. Other peers receive this over pubsub, decrypt the message and verify the signature. If everything is ok, they then display the message in their UI against the sender's nick, peer ID and timestamp. IPNS-pubsub is enabled to aid in resolving IPNS names as quickly as possible, and reducing the dependence on DHT. File or directory sharingDirectories, when shared, are first archived through Shared files are encrypted using their SHA1 hash and then added to IPFS. The CID of the added file and the aforementioned encrypting hash are then sent to the chatroom peer(s) in a general or private message. The receiving peer(s) decrypt the CID and encryption hash, retrieve the encrypted file over IPFS and decrypt the same. (TBD: After decryption, receivers may check the file against the SHA1 hash received). The purpose of encrypting a file with its own hash is to generate the same output every time the same file is encrypted. This causes deduplication. For example, if A and B encrypt and share the same file with C, C only has to download the file once. Because of the content-addressability of IPFS, deduplicated objects would also have more providers, thus increasing availability and hence improving download time. To minimize disk usage by the downloaded and decrypted files, Encrypting large files is time-consuming. Files once encrypted are therefore cached in the global filestore. Also, adding large encrypted files to IPFS is time-consuming. To avoid encrypting and adding the same file again and again, as long as the IPFS node is online, for every shared file, it maintains a map of the file-hash to its encrypted file CID. Note: SHA1 is preferred to other hashes merely for speed. (TBD: For added security, the SHA1 hash of the file may be salted, derived as: EfficiencyIPFS usually consumes a lot of bandwidth. To make it more efficient, all unnecessary connections are closed at regular intervals: The node maintains a list of all chatroom peers seen or discovered in a session. All other connections, except connections to the relays that the node itself or its chatroom peers are connected to, are culled on a frequent basis. New connections are always being formed to nodes within the general IPFS network. The interval between consecutive cullings is large enough to gather sufficient number of nodes for performing DHT operations such as providing the rendezvous file, finding other providers and finding the multiaddresses of those providers. Once these operations are finished, the culling is performed. Connections to the chatroom peers are never closed. To achieve this, The IPFS repo is also garbage-cleaned frequently to clear any irrelevant (unpinned) blocks. Less blocks in cache means smaller IHAVE lists and thereby less providing to directly connected peers. Simple Note that the connection manager and frequent repo cleanup reduce bandwidth only at the cost of CPU. The go-ipfs config file has been tuned to reduce resource (CPU/bandwidth/memory) consumption. WAN-only and LAN-only modes are available (see Usage) to further optimize resource consumption under different situations. To minimize disk usage wherever possible, IPFS-filestore is used. For efficiency regarding file-sharing, see File or directory sharing. Tip: To show bandwidth usage by the node at the end of a session, launch Fully decentralized vs (Semi-)centralizedApart from its dependence on a set of of bootstrap and relay nodes, Future directions
ContributePost at issues and discussion, or write to me.
GNU GPL v3-or-later © 2021 Somajit Dey |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论