Class: CARPS::Peer
- Inherits:
-
UserConfig
- Object
- YamlConfig
- UserConfig
- CARPS::Peer
- Defined in:
- lib/carps/crypt/peer.rb
Overview
Peers
Instance Method Summary collapse
- #addr ⇒ Object
-
#initialize(addr) ⇒ Peer
constructor
Create a new peer.
-
#save ⇒ Object
Save as YAML file in .peers.
-
#verify(mail) ⇒ Object
Perform a verification on an email.
-
#your_key(key) ⇒ Object
Tell this peer its key.
Methods inherited from UserConfig
Methods inherited from YamlConfig
Constructor Details
#initialize(addr) ⇒ Peer
Create a new peer
64 65 66 |
# File 'lib/carps/crypt/peer.rb', line 64 def initialize addr @addr = addr end |
Instance Method Details
#addr ⇒ Object
68 69 70 |
# File 'lib/carps/crypt/peer.rb', line 68 def addr @addr end |
#save ⇒ Object
Save as YAML file in .peers
95 96 97 98 99 100 101 102 |
# File 'lib/carps/crypt/peer.rb', line 95 def save y = emit.to_yaml begin write_file_in ".peers/", y rescue StandardError => e UI::warn "Could not save Peer in .peers/" end end |
#verify(mail) ⇒ Object
Perform a verification on an email
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/carps/crypt/peer.rb', line 78 def verify mail sig, dig = mail.crypt begin pass = @peer_key.sysverify dig, sig rescue OpenSSL::PKey::DSAError => e UI::warn "Someone sent you an invalid signature: #{e.}" return false end if pass return true else UI::warn "Someone has attempted to spoof an email from #{mail.from}", mail.to_s return false end end |
#your_key(key) ⇒ Object
Tell this peer its key
73 74 75 |
# File 'lib/carps/crypt/peer.rb', line 73 def your_key key @peer_key = key end |