From 5e576d9d4a0e0074b28bf857941d544e3646975f Mon Sep 17 00:00:00 2001
From: idk
Date: Thu, 4 Aug 2022 00:02:05 -0400
Subject: [PATCH] update index.html
---
DOCS.md | 37 ++++++++++++++++++++++++++++++-------
README.md | 27 +++++++++++++++++++++++----
common.go | 10 ++++++++++
garlic.go | 18 ++++++++++++++++++
index.html | 45 ++++++++++++++++++++++++++++++++++++++++++---
5 files changed, 123 insertions(+), 14 deletions(-)
diff --git a/DOCS.md b/DOCS.md
index 9aa967c..c835168 100644
--- a/DOCS.md
+++ b/DOCS.md
@@ -34,21 +34,40 @@ var SAM_ADDR = "127.0.0.1:7656"
## Functions
-### func [Close](/garlic.go#L200)
+### func [Close](/garlic.go#L218)
`func Close(tunName string)`
Close closes the Garlic at the given index. It does not affect Garlic
objects instantiated by an app.
-### func [CloseAll](/garlic.go#L191)
+### func [CloseAll](/garlic.go#L209)
`func CloseAll()`
Close() closes all garlics managed by the onramp package. It does not
affect objects instantiated by an app.
-### func [Dial](/garlic.go#L226)
+### func [DeleteI2PKeyStore](/common.go#L57)
+
+`func DeleteI2PKeyStore() error`
+
+DeleteI2PKeyStore deletes the I2P Keystore.
+
+### func [DeleteKeys](/garlic.go#L157)
+
+`func DeleteKeys(tunName string) error`
+
+DeleteKeys deletes the key file at the given path as determined by
+keystore + tunName.
+
+### func [DeleteTorKeyStore](/common.go#L75)
+
+`func DeleteTorKeyStore() error`
+
+DeleteTorKeyStore deletes the Onion Keystore.
+
+### func [Dial](/garlic.go#L244)
`func Dial(network, addr string) (net.Conn, error)`
@@ -62,7 +81,7 @@ and not instantiated by an app.
GetJoinedWD returns the working directory joined with the given path.
-### func [I2PKeys](/garlic.go#L153)
+### func [I2PKeys](/garlic.go#L171)
`func I2PKeys(tunName, samAddr string) (i2pkeys.I2PKeys, error)`
@@ -77,7 +96,7 @@ I2PKeystorePath returns the path to the I2P Keystore. If the
path is not set, it returns the default path. If the path does
not exist, it creates it.
-### func [Listen](/garlic.go#L214)
+### func [Listen](/garlic.go#L232)
`func Listen(network, keys string) (net.Listener, error)`
@@ -85,7 +104,7 @@ Listen returns a net.Listener for a garlic structure's keys
corresponding to a structure managed by the onramp library
and not instantiated by an app.
-### func [TorKeystorePath](/common.go#L59)
+### func [TorKeystorePath](/common.go#L64)
`func TorKeystorePath() (string, error)`
@@ -102,7 +121,7 @@ not exist, it creates it.
Garlic is a ready-made I2P streaming manager. Once initialized it always
has a valid I2PKeys and StreamSession.
-#### func [NewGarlic](/garlic.go#L136)
+#### func [NewGarlic](/garlic.go#L140)
`func NewGarlic(tunName, samAddr string, options []string) (*Garlic, error)`
@@ -115,6 +134,10 @@ I2P streaming.
Close closes the Garlic structure's sessions and listeners.
+#### func (*Garlic) [DeleteKeys](/garlic.go#L134)
+
+`func (g *Garlic) DeleteKeys() error`
+
#### func (*Garlic) [Dial](/garlic.go#L99)
`func (g *Garlic) Dial(net, addr string) (net.Conn, error)`
diff --git a/README.md b/README.md
index 5e1c282..452b77d 100644
--- a/README.md
+++ b/README.md
@@ -6,8 +6,25 @@ Provides only the most widely-used functions in a basic way. It expects nothing
from the users, an otherwise empty instance of the structs will listen and dial
I2P Streaming and Tor TCP sessions successfully.
-I2P(Garlic) Usage:
-------------------
+In all cases, it assumes that keys are "persistent" in that they are managed
+maintained between usages of the same application in the same configuration.
+This means that hidden services will maintain their identities, and that clients
+will always have the same return addresses. If you don't want this behavior,
+make sure to delete the "keystore" when your app closes or when your application
+needs to cycle keys by calling the `Garlic.DeleteKeys()` function.
+
+Usage
+-----
+
+Basic usage is designed to be very simple, import the package and instantiate
+a struct and you're ready to go.
+
+For more extensive examples, see: [EXAMPLE](example.md)
+
+### I2P(Garlic) Usage:
+
+When using it to manage an I2P session, set up an `onramp.Garlic`
+struct.
```Go
package main
@@ -29,8 +46,10 @@ func main() {
}
```
-Tor(Onion) Usage:
------------------
+### Tor(Onion) Usage:
+
+When using it to manage a Tor session, set up an `onramp.Onion`
+struct.
```Go
package main
diff --git a/common.go b/common.go
index e353682..b181765 100644
--- a/common.go
+++ b/common.go
@@ -53,6 +53,11 @@ func I2PKeystorePath() (string, error) {
return I2P_KEYSTORE_PATH, nil
}
+// DeleteI2PKeyStore deletes the I2P Keystore.
+func DeleteI2PKeyStore() error {
+ return os.RemoveAll(I2P_KEYSTORE_PATH)
+}
+
// TorKeystorePath returns the path to the Onion Keystore. If the
// path is not set, it returns the default path. If the path does
// not exist, it creates it.
@@ -65,3 +70,8 @@ func TorKeystorePath() (string, error) {
}
return ONION_KEYSTORE_PATH, nil
}
+
+// DeleteTorKeyStore deletes the Onion Keystore.
+func DeleteTorKeyStore() error {
+ return os.RemoveAll(ONION_KEYSTORE_PATH)
+}
diff --git a/garlic.go b/garlic.go
index 21cf4d8..499cc98 100644
--- a/garlic.go
+++ b/garlic.go
@@ -131,6 +131,10 @@ func (g *Garlic) Keys() (i2pkeys.I2PKeys, error) {
return keys, nil
}
+func (g *Garlic) DeleteKeys() error {
+ return DeleteKeys(g.getName())
+}
+
// NewGarlic returns a new Garlic struct. It is immediately ready to use with
// I2P streaming.
func NewGarlic(tunName, samAddr string, options []string) (*Garlic, error) {
@@ -148,6 +152,20 @@ func NewGarlic(tunName, samAddr string, options []string) (*Garlic, error) {
return g, nil
}
+// DeleteKeys deletes the key file at the given path as determined by
+// keystore + tunName.
+func DeleteKeys(tunName string) error {
+ keystore, err := I2PKeystorePath()
+ if err != nil {
+ return fmt.Errorf("onramp DeleteKeys: discovery error %v", err)
+ }
+ keyspath := filepath.Join(keystore, tunName+".i2p.private")
+ if err := os.Remove(keyspath); err != nil {
+ return fmt.Errorf("onramp DeleteKeys: %v", err)
+ }
+ return nil
+}
+
// I2PKeys returns the I2PKeys at the keystore directory for the given
// tunnel name. If none exist, they are created and stored.
func I2PKeys(tunName, samAddr string) (i2pkeys.I2PKeys, error) {
diff --git a/index.html b/index.html
index 64fa2f5..7df127c 100644
--- a/index.html
+++ b/index.html
@@ -50,9 +50,41 @@
from the users, an otherwise empty instance of the structs will listen and dial
I2P Streaming and Tor TCP sessions successfully.
+
+ In all cases, it assumes that keys are “persistent” in that they are managed
+ maintained between usages of the same application in the same configuration.
+ This means that hidden services will maintain their identities, and that clients
+ will always have the same return addresses. If you don’t want this behavior,
+ make sure to delete the “keystore” when your app closes or when your application
+ needs to cycle keys by calling the
+
+ Garlic.DeleteKeys()
+
+ function.
+
- I2P(Garlic) Usage:
+ Usage
+
+ Basic usage is designed to be very simple, import the package and instantiate
+ a struct and you’re ready to go.
+
+
+ For more extensive examples, see:
+
+ EXAMPLE
+
+
+
+ I2P(Garlic) Usage:
+
+
+ When using it to manage an I2P session, set up an
+
+ onramp.Garlic
+
+ struct.
+
package main
import(
@@ -71,9 +103,16 @@ func main() {
defer listener.Close()
}
-
+
Tor(Onion) Usage:
-
+
+
+ When using it to manage a Tor session, set up an
+
+ onramp.Onion
+
+ struct.
+
package main
import(