Cleanup and test scripts. TODO: Why does blocking not delete previous peers?
This commit is contained in:
parent
fbed8ccc21
commit
f0cebae13d
|
@ -12,28 +12,23 @@ Eg: `pigeon identity show` becomes `./pigeon-cli show`.
|
|||
|
||||
# Current Status
|
||||
|
||||
- [X] pigeon status
|
||||
- [X] pigeon identity new
|
||||
- [X] pigeon identity show
|
||||
|
||||
- [X] pigeon status
|
||||
- [X] pigeon blob set
|
||||
- [X] pigeon blob get
|
||||
|
||||
- [X] pigeon peer add
|
||||
- [X] pigeon peer remove
|
||||
- [X] pigeon peer block
|
||||
- [ ] pigeon peer all
|
||||
|
||||
- [ ] pigeon message new
|
||||
- [ ] pigeon message current
|
||||
- [ ] pigeon message append
|
||||
- [ ] pigeon message save
|
||||
- [ ] pigeon message find
|
||||
- [ ] pigeon message find-all
|
||||
|
||||
- [ ] pigeon bundle create
|
||||
- [ ] pigeon bundle consume
|
||||
|
||||
- [ ] 100% documentation
|
||||
- [ ] 100% coverage
|
||||
- [ ] add parsers and validators for all CLI inputs
|
||||
|
|
15
TODO.md
15
TODO.md
|
@ -3,12 +3,6 @@ I need to implement these.
|
|||
I'm adding them here for quick reference.
|
||||
|
||||
```bash
|
||||
pigeon status
|
||||
# => BLOBS: 10,234
|
||||
# => PEERS: 26
|
||||
# => VERSION: 0.0.1
|
||||
# => FOO: BAR
|
||||
|
||||
pigeon message new my_message
|
||||
# => "Switched to message `my_message`
|
||||
|
||||
|
@ -60,15 +54,6 @@ pigeon message find-all --author=@ajgdylxeifojlxpbmen3exlnsbx8buspsjh37b/ipvi=.e
|
|||
# => &ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb.sha256:&2e7a0bc31f3c4fe6114051c3a56c8ed8a030b3b394df7d29d37648e9b8cbf54b.sha256
|
||||
# =>
|
||||
|
||||
pigeon peer add @m0LEP+0NrGqu1wT8/4a3nOPuRBM+DrMpUahDZ3/cDi8=.ed25519
|
||||
# =>
|
||||
|
||||
pigeon peer remove @78daXMc/BOq5F1RWLMN4zgPVBVLqA4ShkLgE6z9OUGQ=.ed25519
|
||||
# =>
|
||||
|
||||
pigeon peer block @GOl+398b2kWeLi6+DCcU0i3AWD6vWmUtocBVYbpkpNk=.ed25519
|
||||
# =>
|
||||
|
||||
pigeon peer all
|
||||
# => @c8hovH5OOzNJ1SXUsIN+zI23xMcvGdEbs3ZJgzpthrw=.ed25519
|
||||
# => @GOl+398b2kWeLi6+DCcU0i3AWD6vWmUtocBVYbpkpNk=.ed25519
|
||||
|
|
|
@ -13,6 +13,14 @@ module Pigeon
|
|||
raise "TODO"
|
||||
end
|
||||
|
||||
def self.strip_headers(identity)
|
||||
identity.sub(HEADER, "").sub(FOOTER, "")
|
||||
end
|
||||
|
||||
def self.add_headers(urlsafe_b64_no_headers)
|
||||
[HEADER, urlsafe_b64_no_headers, FOOTER].join("")
|
||||
end
|
||||
|
||||
# `seed` is a 32-byte seed value from which
|
||||
# the key should be derived
|
||||
def initialize(seed = SecureRandom.random_bytes(Ed25519::KEY_SIZE))
|
||||
|
@ -28,7 +36,7 @@ module Pigeon
|
|||
bytes = @raw_key.verify_key.to_bytes
|
||||
b64 = Base64.urlsafe_encode64(bytes)
|
||||
|
||||
@public_key ||= [HEADER, b64, FOOTER].join("")
|
||||
@public_key ||= KeyPair.add_headers(b64)
|
||||
end
|
||||
|
||||
def save!
|
||||
|
|
|
@ -54,34 +54,32 @@ module Pigeon
|
|||
end
|
||||
|
||||
def urlsafe_base64(identity)
|
||||
Base64.urlsafe_decode64(identity
|
||||
.gsub(KeyPair::HEADER, "")
|
||||
.gsub(KeyPair::FOOTER, ""))
|
||||
end
|
||||
|
||||
def from_base36(identity)
|
||||
Base64
|
||||
.urlsafe_decode64(KeyPair.strip_headers(identity))
|
||||
end
|
||||
|
||||
def add_peer(identity)
|
||||
path = urlsafe_base64(identity)
|
||||
path = KeyPair.strip_headers(identity)
|
||||
FileUtils.mkdir_p(File.join(peer_dir, path))
|
||||
identity
|
||||
end
|
||||
|
||||
def remove_peer(identity)
|
||||
path = urlsafe_base64(identity)
|
||||
FileUtils.rm_rf(path)
|
||||
FileUtils.rm_rf(KeyPair.strip_headers(identity))
|
||||
identity
|
||||
end
|
||||
|
||||
def block_peer(identity)
|
||||
remove_peer(identity)
|
||||
path = urlsafe_base64(identity)
|
||||
path = KeyPair.strip_headers(identity)
|
||||
FileUtils.touch(File.join(block_dir, path))
|
||||
identity
|
||||
end
|
||||
|
||||
def all_peers
|
||||
all = Dir[File.join(peer_dir, "*")]
|
||||
Dir[File.join(peer_dir, "*")]
|
||||
.map { |x| File.split(x).last }
|
||||
binding.pry
|
||||
.map { |x| KeyPair.add_headers(x) }
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -50,19 +50,19 @@ module Pigeon
|
|||
desc "add", "Begin following a Pigeon peer"
|
||||
|
||||
def add(identity)
|
||||
Pigeon::Storage.current.add_peer(identity)
|
||||
puts Pigeon::Storage.current.add_peer(identity)
|
||||
end
|
||||
|
||||
desc "remove", "Stop following a Pigeon peer"
|
||||
|
||||
def remove(identity)
|
||||
Pigeon::Storage.current.remove_peer(identity)
|
||||
puts Pigeon::Storage.current.remove_peer(identity)
|
||||
end
|
||||
|
||||
desc "block", "Stop following a Pigeon peer AND refuse to replicate"
|
||||
|
||||
def block(identity)
|
||||
Pigeon::Storage.current.block_peer(identity)
|
||||
puts Pigeon::Storage.current.block_peer(identity)
|
||||
end
|
||||
|
||||
desc "all", "List all Pigeon peers"
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 98 KiB |
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/env fish
|
||||
|
||||
# This is a script that
|
||||
# run all CLI commands at once
|
||||
# for quick QA.
|
||||
|
||||
echo "Deleting old pigeon configs"
|
||||
rm -rf .pigeon/
|
||||
echo "OK"
|
||||
|
||||
echo "Creating new config:"
|
||||
./pigeon-cli identity new
|
||||
./pigeon-cli identity show
|
||||
|
||||
echo "Creating kitty cat blobs:"
|
||||
cat scratchpad.jpg | ./pigeon-cli blob set
|
||||
|
||||
echo "Adding peers:"
|
||||
./pigeon-cli peer add @_TlC2z3FT4fimecC4eytrBhOwhLUZsVBZEZriBO9cWs=.ed25519
|
||||
./pigeon-cli peer add @28FyT7evjcYrrwngr8G2V1HZ0ODK0VPsFctDEZwfZJc=.ed25519
|
||||
./pigeon-cli peer add @ExA5Fmld-vMDjROfN30G5pmSp_261QILFP3qe64iDn8=.ed25519
|
||||
./pigeon-cli peer add @galdahnB3L2DE2cTU0Me54IpIUKVEgKmBwvZVtWJccg=.ed25519
|
||||
./pigeon-cli peer add @I6cN_IE9iPmH05xXnlI_WyLqnrAoKv1plUKWfiGSSK4=.ed25519
|
||||
./pigeon-cli peer add @JnCKDs5tIzY9OF--GFT94Qj5jHtK7lTxqCt1tmPcwjM=.ed25519
|
||||
./pigeon-cli peer add @q-_9BTnTThvW2ZGkmy8D3j-hW9ON2PNa3nwbCQgRw-g=.ed25519
|
||||
./pigeon-cli peer add @VIim19-PzaavRICicQg4c4z08SoWTa1tr2e-kfhmm0Y=.ed25519
|
||||
|
||||
echo "removing peers:"
|
||||
./pigeon-cli peer remove @mYWRsosFtoxvn3GURmmE0FVtOWPcYv4ovXIAqy49sH4=.ed25519
|
||||
./pigeon-cli peer remove @Nf7ZU9fLwukgfRfCunDtfjXRlhitiR-DcTmlNhB8lwk=.ed25519
|
||||
|
||||
echo "blocking peers:"
|
||||
./pigeon-cli peer block @q-_9BTnTThvW2ZGkmy8D3j-hW9ON2PNa3nwbCQgRw-g=.ed25519
|
||||
./pigeon-cli peer block @VIim19-PzaavRICicQg4c4z08SoWTa1tr2e-kfhmm0Y=.ed25519
|
||||
./pigeon-cli peer block @VMSPmcYm1qXJy27V_MH1HGA7Mr3sOMikKOwfxT26hQg=.ed25519
|
||||
|
||||
echo "listing all peers:"
|
||||
./pigeon-cli peer all
|
||||
|
||||
echo "getting status:"
|
||||
./pigeon-cli status
|
Loading…
Reference in New Issue