mirror of
https://github.com/nestriness/nestri.git
synced 2025-12-13 01:05:37 +02:00
## Description Whew, some stuff is still not re-implemented, but it's working! Rabbit's gonna explode with the amount of changes I reckon 😅 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a peer-to-peer relay system using libp2p with enhanced stream forwarding, room state synchronization, and mDNS peer discovery. - Added decentralized room and participant management, metrics publishing, and safe, size-limited, concurrent message streaming with robust framing and callback dispatching. - Implemented asynchronous, callback-driven message handling over custom libp2p streams replacing WebSocket signaling. - **Improvements** - Migrated signaling and stream protocols from WebSocket to libp2p, improving reliability and scalability. - Simplified configuration and environment variables, removing deprecated flags and adding persistent data support. - Enhanced logging, error handling, and connection management for better observability and robustness. - Refined RTP header extension registration and NAT IP handling for improved WebRTC performance. - **Bug Fixes** - Improved ICE candidate buffering and SDP negotiation in WebRTC connections. - Fixed NAT IP and UDP port range configuration issues. - **Refactor** - Modularized codebase, reorganized relay and server logic, and removed deprecated WebSocket-based components. - Streamlined message structures, removed obsolete enums and message types, and simplified SafeMap concurrency. - Replaced WebSocket signaling with libp2p stream protocols in server and relay components. - **Chores** - Updated and cleaned dependencies across Go, Rust, and JavaScript packages. - Added `.gitignore` for persistent data directory in relay package. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: DatCaptainHorse <DatCaptainHorse@users.noreply.github.com> Co-authored-by: Philipp Neumann <3daquawolf@gmail.com>
47 lines
1022 B
Go
47 lines
1022 B
Go
package resource
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"os"
|
|
"reflect"
|
|
)
|
|
|
|
type Resource struct {
|
|
Api struct {
|
|
Url string `json:"url"`
|
|
}
|
|
Auth struct {
|
|
Url string `json:"url"`
|
|
}
|
|
/*AuthFingerprintKey struct {
|
|
Value string `json:"value"`
|
|
}*/
|
|
Realtime struct {
|
|
Endpoint string `json:"endpoint"`
|
|
Authorizer string `json:"authorizer"`
|
|
}
|
|
App struct {
|
|
Name string `json:"name"`
|
|
Stage string `json:"stage"`
|
|
}
|
|
}
|
|
|
|
func NewResource() (*Resource, error) {
|
|
resource := Resource{}
|
|
val := reflect.ValueOf(&resource).Elem()
|
|
for i := 0; i < val.NumField(); i++ {
|
|
field := val.Field(i)
|
|
typeField := val.Type().Field(i)
|
|
envVarName := fmt.Sprintf("SST_RESOURCE_%s", typeField.Name)
|
|
envValue, exists := os.LookupEnv(envVarName)
|
|
if !exists {
|
|
return nil, fmt.Errorf("missing environment variable %s", envVarName)
|
|
}
|
|
if err := json.Unmarshal([]byte(envValue), field.Addr().Interface()); err != nil {
|
|
return nil, fmt.Errorf("error unmarshalling %s: %w", envVarName, err)
|
|
}
|
|
}
|
|
return &resource, nil
|
|
}
|