Merge branch 'master' into config

This commit is contained in:
idk
2024-11-03 22:25:05 +00:00
committed by GitHub
4 changed files with 85 additions and 65 deletions

View File

@ -1,18 +0,0 @@
At long last... something useful
================================
It's been 2 years of me mostly not having time to work on go-i2p itself since my last update.
However, after much waiting, this library is actually **useful** for something.
It is now being used in the `reseed-tools` application to examine RouterInfos prior to including them in reseed bundles.
Routers that self-report as unreachable or congested will be excluded from future reseed bundles.
Additionally, routers that self-report an old version will be excluded from reseed bundles.
This should help new users build better connections faster with the existing, working router implementations.
This is not a working release of a go-i2p router
------------------------------------------------
It is a numbered version of the go-i2p library, which is pre-release, expressly for use in the `reseed-tools` application.
The common library works, and so do some of the cryptographic primitives, however the API is unstable and the software itself is certain to have serious bugs outside of a few well-tested areas.
If you're using it for something other than parsing and analyzing RouterInfos and LeaseSets, you'll probably encounter bugs.
Please report them to the https://github.com/go-i2p/go-i2p
Use any part of it at your own risk.

41
ROADMAP.md Normal file
View File

@ -0,0 +1,41 @@
# go-i2p Implementation Roadmap
## Transport Layer (NTCP2)
- Build on existing lib/transport/noise implementation
- Core NTCP2 components:
* Session handshake using noise protocol
* Connection management
* I2NP message transport
## Reseed System
- SU3 file format implementation:
* Format parsing and validation(Much of this work is done in reseed-tools, may need to be moved here)
* Signature verification system(Much of this work is done in reseed-tools, may need to be moved here)
- Local reseed functionality:
* File-based reseed operations
- Self-signed/Package-pinned X.509 certificate handling for reseed validation
## NetDb and Database Store
- Database Store message handling:
* Message structure implementation
* Message handling implementation
- NetDb core implementation:
* RouterInfo management
* LeaseSet management
* Lookup system
* Storage interface
* Peer selection logic?(Maybe do something very basic for now like i2pd used to do, and then improve it later, the important part will be interface design at first)
## Tunnel Implementation
- Tunnel cryptography:
* Key generation and management
* Layered encryption scheme
- Message processing:
* Build request/response handling
* Gateway implementation
* Message forwarding logic
Notes:
- Excluding legacy protocols (SSU1, NTCP1, elgamal, DSA)
- Leveraging existing noise protocol implementation
- SSU2 is not on this roadmap but is fair game for implementation as soon as NTCP2 is done. We're focused on NTCP2 to get this thing sending I2NP messages.

1
go.mod
View File

@ -40,4 +40,5 @@ require (
golang.org/x/sys v0.25.0 // indirect
golang.org/x/text v0.18.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

View File

@ -69,59 +69,55 @@ func (r Reseed) SingleReseed(uri string) ([]router_info.RouterInfo, error) {
if su3file.FileType == su3.ZIP {
if su3file.ContentType == su3.RESEED {
content, err := io.ReadAll(su3file.Content(""))
if err == nil {
content, err := io.ReadAll(su3file.Content(""))
if err == nil {
signature, err := io.ReadAll(su3file.Signature())
if err != nil {
return nil, err
}
log.Println("warning: this doesn't validate the signature yet", signature)
log.Warn("Doesn't validate the signature yet", logrus.Fields{"signature": signature})
}
zip := filepath.Join(config.RouterConfigProperties.NetDb.Path, "reseed.zip")
err = os.WriteFile(zip, content, 0o644)
signature, err := io.ReadAll(su3file.Signature())
if err != nil {
log.WithError(err).Error("Failed to write reseed zip file")
log.WithError(err).Error("Failed to read SU3 file signature")
return nil, err
}
// content is a zip file, unzip it and get the files
files, err := unzip.New().Extract(zip, config.RouterConfigProperties.NetDb.Path)
if err != nil {
log.WithError(err).Error("Failed to extract reseed zip file")
return nil, err
}
if len(files) <= 0 {
log.Error("Reseed appears to have no content")
return nil, fmt.Errorf("error: reseed appears to have no content")
}
log.WithField("file_count", len(files)).Debug("Successfully extracted reseed files")
var ris []router_info.RouterInfo
for _, f := range files {
riB, err := os.ReadFile(f)
if err != nil {
log.WithError(err).WithField("file", f).Warn("Failed to read router info file")
continue
}
ri, _, err := router_info.ReadRouterInfo(riB)
if err != nil {
log.WithError(err).WithField("file", f).Warn("Failed to parse router info")
continue
}
ris = append(ris, ri)
}
err = os.Remove(zip)
if err != nil {
log.WithError(err).Warn("Failed to remove reseed zip file")
}
log.WithField("router_info_count", len(ris)).Debug("Successfully processed reseed data")
return ris, err
} else {
log.WithError(err).Error("Failed to read SU3 file signature")
log.Println("warning: this doesn't validate the signature yet", signature)
log.Warn("Doesn't validate the signature yet", logrus.Fields{"signature": signature})
}
zip := filepath.Join(config.RouterConfigProperties.NetDb.Path, "reseed.zip")
err = os.WriteFile(zip, content, 0o644)
if err != nil {
log.WithError(err).Error("Failed to write reseed zip file")
return nil, err
}
// content is a zip file, unzip it and get the files
files, err := unzip.New().Extract(zip, config.RouterConfigProperties.NetDb.Path)
if err != nil {
log.WithError(err).Error("Failed to extract reseed zip file")
return nil, err
}
if len(files) <= 0 {
log.Error("Reseed appears to have no content")
return nil, fmt.Errorf("error: reseed appears to have no content")
}
log.WithField("file_count", len(files)).Debug("Successfully extracted reseed files")
var ris []router_info.RouterInfo
for _, f := range files {
riB, err := os.ReadFile(f)
if err != nil {
log.WithError(err).WithField("file", f).Warn("Failed to read router info file")
continue
}
ri, _, err := router_info.ReadRouterInfo(riB)
if err != nil {
log.WithError(err).WithField("file", f).Warn("Failed to parse router info")
continue
}
ris = append(ris, ri)
}
err = os.Remove(zip)
if err != nil {
log.WithError(err).Warn("Failed to remove reseed zip file")
}
log.WithField("router_info_count", len(ris)).Debug("Successfully processed reseed data")
return ris, err
}
}
log.Error("Undefined reseed error")