# server ```go import "github.com/Akilan1999/p2p-rendering-computation/server" ``` source:https://github.com/afoley587/go-rev-proxy/tree/main ## Index - [Variables](<#variables>) - [func GetScheme\(c \*gin.Context\) string](<#GetScheme>) - [func MapPort\(port string, domainName string, serverAddress string\) \(string, string, error\)](<#MapPort>) - [func Proxy\(c \*gin.Context\)](<#Proxy>) - [func ProxyRun\(port string\)](<#ProxyRun>) - [func SaveRegistration\(OutsideHost string, InsideHost string\) error](<#SaveRegistration>) - [func Server\(\) \(\*gin.Engine, error\)](<#Server>) - [type Gpu](<#Gpu>) - [type GpuClock](<#GpuClock>) - [type GpuTemperature](<#GpuTemperature>) - [type GpuUtilization](<#GpuUtilization>) - [type Query](<#Query>) - [func GPUInfo\(\) \(\*Query, error\)](<#GPUInfo>) - [type RegistrationRequest](<#RegistrationRequest>) - [type ReverseProxy](<#ReverseProxy>) - [type SysInfo](<#SysInfo>) - [func ServerInfo\(\) \*SysInfo](<#ServerInfo>) ## Variables ```go var ( //RunPort = 2002 // The server port to run on //ReverseServerAddr = fmt.Sprint("0.0.0.0:", RunPort) // this is our reverse server ip address //InsideProxyHostname = fmt.Sprint("proxy:", RunPort) // Requests from private network //OutsideProxyHostname = fmt.Sprint("registration.localhost:", RunPort) // Requests from public network KnownAddresses = map[string]string{} // Known Addresses ) ``` ReverseProxies Reverse to the map such as ReverseProxies\[\\]ReverseProxy type ```go var ReverseProxies map[string]ReverseProxy ``` ## func [GetScheme]() ```go func GetScheme(c *gin.Context) string ``` This function checks if TLS was enabled on the request and translates it to the proper scheme \(http or https\) ## func [MapPort]() ```go func MapPort(port string, domainName string, serverAddress string) (string, string, error) ``` ## func [Proxy]() ```go func Proxy(c *gin.Context) ``` Proxy runs the actual proxy and will look at the hostnames requested from the received request. It will then translate that to the inside hostname and forward the request ## func [ProxyRun]() ```go func ProxyRun(port string) ``` ## func [SaveRegistration]() ```go func SaveRegistration(OutsideHost string, InsideHost string) error ``` SaveRegistration Creates registration of proxy node ## func [Server]() ```go func Server() (*gin.Engine, error) ``` ## type [Gpu]() ```go type Gpu struct { GpuName string `xml:"product_name"` BiosVersion string `xml:"vbios_version"` FanSpeed string `xml:"fan_speed"` Utilization GpuUtilization `xml:"utilization"` Temperature GpuTemperature `xml:"temperature"` Clock GpuClock `xml:"clocks"` } ``` ## type [GpuClock]() ```go type GpuClock struct { GpuClock string `xml:"graphics_clock"` GpuMemClock string `xml:"mem_clock"` } ``` ## type [GpuTemperature]() ```go type GpuTemperature struct { GpuTemp string `xml:"gpu_temp"` } ``` ## type [GpuUtilization]() ```go type GpuUtilization struct { GpuUsage string `xml:"gpu_util"` MemoryUsage string `xml:"memory_util"` } ``` ## type [Query]() ```go type Query struct { DriveVersion string `xml:"driver_version"` Gpu Gpu `xml:"gpu"` } ``` ### func [GPUInfo]() ```go func GPUInfo() (*Query, error) ``` Gets GPU information by calling nvidia\-smi in XML output ## type [RegistrationRequest]() ```go type RegistrationRequest struct { OutsideHost string // Outside host address. The hostname or IP on the public network. For example foo.bar.com or foo.localhost InsideHost string // Inside host address. The hostname or IP on the internal network. For example 192.168.10.5 } ``` ## type [ReverseProxy]() ```go type ReverseProxy struct { IPAddress string Port string } ``` ## type [SysInfo]() SysInfo saves the basic system information ```go type SysInfo struct { Hostname string `bson:hostname` Platform string `bson:platform` CPU string `bson:cpu` RAM uint64 `bson:ram` Disk uint64 `bson:disk` GPU *Query `xml: GpuInfo` } ``` ### func [ServerInfo]() ```go func ServerInfo() *SysInfo ``` Generated by [gomarkdoc]()