pushed final docs for initial merge

This commit is contained in:
2025-01-21 21:08:22 +00:00
parent 1bd3a35992
commit a07f9588fb
17 changed files with 2774 additions and 6 deletions

303
p2p/docs.md Normal file
View File

@@ -0,0 +1,303 @@
<!-- Code generated by gomarkdoc. DO NOT EDIT -->
# p2p
```go
import "github.com/Akilan1999/p2p-rendering-computation/p2p"
```
## Index
- [func AddAuthorisationKey\(PublicKey string\) error](<#AddAuthorisationKey>)
- [func AddKeyToAuthorizedKeys\(path, newKey string\) error](<#AddKeyToAuthorizedKeys>)
- [func CurrentPublicIP\(\) \(string, error\)](<#CurrentPublicIP>)
- [func ForwardPort\(port int\) error](<#ForwardPort>)
- [func GenerateHashSHA256\(text string\) \[\]byte](<#GenerateHashSHA256>)
- [func GetAuthorizedKeysPath\(\) \(string, error\)](<#GetAuthorizedKeysPath>)
- [func GetCurrentIPV6\(\) \(string, error\)](<#GetCurrentIPV6>)
- [func Ip4or6\(s string\) string](<#Ip4or6>)
- [func LocalSpeedTestIpTable\(\) error](<#LocalSpeedTestIpTable>)
- [func PrettyPrint\(data interface\{\}\)](<#PrettyPrint>)
- [func PrintIpTable\(\) error](<#PrintIpTable>)
- [func ReadAuthorizedKeys\(path string\) \(map\[string\]bool, error\)](<#ReadAuthorizedKeys>)
- [func RemoveKeyFromAuthorizedKeys\(path, keyToRemove string\) error](<#RemoveKeyFromAuthorizedKeys>)
- [func UnForwardPort\(port int\) error](<#UnForwardPort>)
- [func ValidateHashSHA256\(text string, Hash \[\]byte\) bool](<#ValidateHashSHA256>)
- [func ViewNetworkInterface\(\) error](<#ViewNetworkInterface>)
- [type IP](<#IP>)
- [type IpAddress](<#IpAddress>)
- [func \(s \*IpAddress\) DownloadSpeed\(\) error](<#IpAddress.DownloadSpeed>)
- [func \(s \*IpAddress\) PingTest\(\) error](<#IpAddress.PingTest>)
- [func \(s \*IpAddress\) UploadSpeed\(\) error](<#IpAddress.UploadSpeed>)
- [type IpAddresses](<#IpAddresses>)
- [func ReadIpTable\(\) \(\*IpAddresses, error\)](<#ReadIpTable>)
- [func \(table \*IpAddresses\) RemoveDuplicates\(\) error](<#IpAddresses.RemoveDuplicates>)
- [func \(ip \*IpAddresses\) SpeedTest\(\) error](<#IpAddresses.SpeedTest>)
- [func \(ip \*IpAddresses\) SpeedTestUpdatedIPTable\(\) error](<#IpAddresses.SpeedTestUpdatedIPTable>)
- [func \(i \*IpAddresses\) WriteIpTable\(\) error](<#IpAddresses.WriteIpTable>)
<a name="AddAuthorisationKey"></a>
## func [AddAuthorisationKey](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/ssh_autorisation.go#L105>)
```go
func AddAuthorisationKey(PublicKey string) error
```
AddAuthorisationKey Adds public key provided to the authorization file so that nodes can SSH into the
<a name="AddKeyToAuthorizedKeys"></a>
## func [AddKeyToAuthorizedKeys](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/ssh_autorisation.go#L48>)
```go
func AddKeyToAuthorizedKeys(path, newKey string) error
```
AddKeyToAuthorizedKeys adds a new key to the authorized\_keys file if it doesnt already exist
<a name="CurrentPublicIP"></a>
## func [CurrentPublicIP](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/iptable.go#L180>)
```go
func CurrentPublicIP() (string, error)
```
CurrentPublicIP Get Current Public IP address
<a name="ForwardPort"></a>
## func [ForwardPort](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/upnp.go#L9>)
```go
func ForwardPort(port int) error
```
Port forwarding to the router
<a name="GenerateHashSHA256"></a>
## func [GenerateHashSHA256](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/iptable.go#L277>)
```go
func GenerateHashSHA256(text string) []byte
```
<a name="GetAuthorizedKeysPath"></a>
## func [GetAuthorizedKeysPath](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/ssh_autorisation.go#L16>)
```go
func GetAuthorizedKeysPath() (string, error)
```
GetAuthorizedKeysPath returns the path to the authorized\_keys file
<a name="GetCurrentIPV6"></a>
## func [GetCurrentIPV6](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/iptable.go#L200>)
```go
func GetCurrentIPV6() (string, error)
```
GetCurrentIPV6 gets the current IPV6 address based on the interface specified in the config file
<a name="Ip4or6"></a>
## func [Ip4or6](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/iptable.go#L253>)
```go
func Ip4or6(s string) string
```
Ip4or6 Helper function to check if the IP address is IPV4 or IPV6 \(https://socketloop.com/tutorials/golang-check-if-ip-address-is-version-4-or-6\)
<a name="LocalSpeedTestIpTable"></a>
## func [LocalSpeedTestIpTable](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/speedtest.go#L122>)
```go
func LocalSpeedTestIpTable() error
```
LocalSpeedTestIpTable Runs speed test in iptables locally only
<a name="PrettyPrint"></a>
## func [PrettyPrint](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/iptable.go#L266>)
```go
func PrettyPrint(data interface{})
```
<a name="PrintIpTable"></a>
## func [PrintIpTable](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/iptable.go#L127>)
```go
func PrintIpTable() error
```
PrintIpTable Print Ip table data for Cli
<a name="ReadAuthorizedKeys"></a>
## func [ReadAuthorizedKeys](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/ssh_autorisation.go#L25>)
```go
func ReadAuthorizedKeys(path string) (map[string]bool, error)
```
ReadAuthorizedKeys reads and returns the current contents of the authorized\_keys file as a map
<a name="RemoveKeyFromAuthorizedKeys"></a>
## func [RemoveKeyFromAuthorizedKeys](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/ssh_autorisation.go#L72>)
```go
func RemoveKeyFromAuthorizedKeys(path, keyToRemove string) error
```
<a name="UnForwardPort"></a>
## func [UnForwardPort](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/upnp.go#L42>)
```go
func UnForwardPort(port int) error
```
UnForwardPort from router
<a name="ValidateHashSHA256"></a>
## func [ValidateHashSHA256](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/iptable.go#L289>)
```go
func ValidateHashSHA256(text string, Hash []byte) bool
```
ValidateHashSHA256 CustomInformationKey the text and check if the text and the hash are the same, if they are then return true SHA256 is the current hashing algorthm used.
<a name="ViewNetworkInterface"></a>
## func [ViewNetworkInterface](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/iptable.go#L227>)
```go
func ViewNetworkInterface() error
```
ViewNetworkInterface This function is created to view the network interfaces available
<a name="IP"></a>
## type [IP](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/iptable.go#L41-L43>)
```go
type IP struct {
Query string
}
```
<a name="IpAddress"></a>
## type [IpAddress](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/iptable.go#L22-L39>)
```go
type IpAddress struct {
Name string `json:"Name"`
MachineUsername string `json:"MachineUsername"`
Ipv4 string `json:"IPV4"`
Ipv6 string `json:"IPV6"`
Latency time.Duration `json:"Latency"`
Download float64 `json:"Download"`
Upload float64 `json:"Upload"`
ServerPort string `json:"ServerPort"`
BareMetalSSHPort string `json:"BareMetalSSHPort"`
NAT string `json:"NAT"`
EscapeImplementation string `json:"EscapeImplementation"`
ProxyServer string `json:"ProxyServer"`
UnSafeMode bool `json:"UnSafeMode"`
PublicKey string `json:"PublicKey"`
CustomInformation string `json:"CustomInformation"`
}
```
<a name="IpAddress.DownloadSpeed"></a>
### func \(\*IpAddress\) [DownloadSpeed](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/testingMetrics.go#L82>)
```go
func (s *IpAddress) DownloadSpeed() error
```
Download Speed
<a name="IpAddress.PingTest"></a>
### func \(\*IpAddress\) [PingTest](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/testingMetrics.go#L152>)
```go
func (s *IpAddress) PingTest() error
```
PingTest executes test to measure latency
<a name="IpAddress.UploadSpeed"></a>
### func \(\*IpAddress\) [UploadSpeed](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/testingMetrics.go#L97>)
```go
func (s *IpAddress) UploadSpeed() error
```
<a name="IpAddresses"></a>
## type [IpAddresses](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/iptable.go#L18-L20>)
```go
type IpAddresses struct {
IpAddress []IpAddress `json:"ip_address"`
}
```
<a name="ReadIpTable"></a>
### func [ReadIpTable](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/iptable.go#L46>)
```go
func ReadIpTable() (*IpAddresses, error)
```
ReadIpTable Read data from Ip tables from json file
<a name="IpAddresses.RemoveDuplicates"></a>
### func \(\*IpAddresses\) [RemoveDuplicates](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/iptable.go#L146>)
```go
func (table *IpAddresses) RemoveDuplicates() error
```
RemoveDuplicates This is a temporary fix current functions failing to remove Duplicate IP addresses from local IP table
<a name="IpAddresses.SpeedTest"></a>
### func \(\*IpAddresses\) [SpeedTest](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/speedtest.go#L8>)
```go
func (ip *IpAddresses) SpeedTest() error
```
SpeedTest Runs a speed test and does updates IP tables accordingly
<a name="IpAddresses.SpeedTestUpdatedIPTable"></a>
### func \(\*IpAddresses\) [SpeedTestUpdatedIPTable](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/speedtest.go#L56>)
```go
func (ip *IpAddresses) SpeedTestUpdatedIPTable() error
```
SpeedTestUpdatedIPTable Called when ip tables from httpclient/server is also passed on
<a name="IpAddresses.WriteIpTable"></a>
### func \(\*IpAddresses\) [WriteIpTable](<https://github.com/Akilan1999/p2p-rendering-computation/blob/master/p2p/iptable.go#L101>)
```go
func (i *IpAddresses) WriteIpTable() error
```
WriteIpTable Write to IP table json file
Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)