From 11822d3e7aed96465c81076997dc47c457fe9c90 Mon Sep 17 00:00:00 2001 From: ucwong Date: Tue, 15 Apr 2025 20:08:14 +0800 Subject: [PATCH] backend & discovery fix --- cmd/cortex/cvm.go | 3 +- cmd/wnode/main.go | 2 +- ctxc/backend.go | 18 ++++---- ctxc/discovery.go | 2 +- go.mod | 4 +- go.sum | 8 ++-- node/node.go | 2 +- node/node_example_test.go | 2 +- node/node_test.go | 10 ++-- node/service.go | 2 +- node/utils_test.go | 8 ++-- .../CortexFoundation/torrentfs/fs.go | 8 +--- .../github.com/pion/webrtc/v4/.golangci.yml | 9 +++- vendor/github.com/pion/webrtc/v4/README.md | 13 +++--- .../github.com/pion/webrtc/v4/icecandidate.go | 7 +-- .../github.com/pion/webrtc/v4/icetransport.go | 4 +- .../github.com/pion/webrtc/v4/mediaengine.go | 36 --------------- vendor/github.com/pion/webrtc/v4/mimetype.go | 46 +++++++++++++++++++ .../pion/webrtc/v4/peerconnection.go | 3 ++ vendor/github.com/pion/webrtc/v4/rtpcodec.go | 11 +++++ vendor/github.com/pion/webrtc/v4/rtpsender.go | 2 +- .../pion/webrtc/v4/sctptransport.go | 11 +++++ vendor/github.com/pion/webrtc/v4/sdp.go | 2 +- vendor/modules.txt | 4 +- whisper/whisperv6/whisper.go | 2 +- whisper/whisperv6/whisper_test.go | 10 ++-- 26 files changed, 131 insertions(+), 98 deletions(-) create mode 100644 vendor/github.com/pion/webrtc/v4/mimetype.go diff --git a/cmd/cortex/cvm.go b/cmd/cortex/cvm.go index 71435ea585..ff3c91f14b 100644 --- a/cmd/cortex/cvm.go +++ b/cmd/cortex/cvm.go @@ -41,7 +41,6 @@ import ( "github.com/CortexFoundation/CortexTheseus/cmd/utils" "github.com/CortexFoundation/CortexTheseus/log" - "github.com/CortexFoundation/CortexTheseus/p2p" ) func homeDir() string { @@ -202,7 +201,7 @@ func cvmServer(ctx *cli.Context) error { return errors.New("fs start failed") } - err = storagefs.Start(&p2p.Server{}) + err = storagefs.Start() if err != nil { return err } diff --git a/cmd/wnode/main.go b/cmd/wnode/main.go index 0961b71eaf..a1ffdf73b7 100644 --- a/cmd/wnode/main.go +++ b/cmd/wnode/main.go @@ -447,7 +447,7 @@ func run() { return } defer server.Stop() - shh.Start(&p2p.Server{}) + shh.Start() defer shh.Stop() if !*forwarderMode { diff --git a/ctxc/backend.go b/ctxc/backend.go index bb467242c3..65d74190da 100644 --- a/ctxc/backend.go +++ b/ctxc/backend.go @@ -276,6 +276,7 @@ func New(stack *node.Node, config *Config) (*Cortex, error) { ctxc.miner = miner.New(ctxc, &config.Miner, ctxc.chainConfig, ctxc.eventMux, ctxc.engine, ctxc.isLocalBlock) ctxc.miner.SetExtra(makeExtraData(config.Miner.ExtraData)) + ctxc.dropper = newDropper(ctxc.p2pServer.MaxDialedConns(), ctxc.p2pServer.MaxInboundConns()) ctxc.APIBackend = &CortexAPIBackend{stack.Config().AllowUnprotectedTxs, ctxc, nil} @@ -287,9 +288,9 @@ func New(stack *node.Node, config *Config) (*Cortex, error) { gpoParams.Default = config.Miner.GasPrice } ctxc.APIBackend.gpo = gasprice.NewOracle(ctxc.APIBackend, gpoParams) - if err != nil { - return nil, err - } + + // Start the RPC service + ctxc.netRPCService = ctxcapi.NewPublicNetAPI(ctxc.p2pServer, networkID) //stack.RegisterProtocols(ctxc.Protocols()) @@ -609,8 +610,7 @@ func (s *Cortex) Protocols() []p2p.Protocol { // Start implements node.Service, starting all internal goroutines needed by the // Cortex protocol implementation. -func (s *Cortex) Start(srvr *p2p.Server) error { - s.startCtxcEntryUpdate(srvr.LocalNode()) +func (s *Cortex) Start() error { if err := s.setupDiscovery(); err != nil { return err } @@ -620,13 +620,9 @@ func (s *Cortex) Start(srvr *p2p.Server) error { // Regularly update shutdown marker s.shutdownTracker.Start() - // Start the RPC service - s.netRPCService = ctxcapi.NewPublicNetAPI(srvr, s.NetVersion()) - // Figure out a max peers count based on the server limits - maxPeers := srvr.MaxPeers // Start the networking layer and the light server if requested - s.protocolManager.Start(maxPeers) + s.protocolManager.Start(s.p2pServer.MaxPeers) // Start the connection manager s.dropper.Start(s.p2pServer, func() bool { return !s.Synced() }) @@ -697,6 +693,8 @@ func (s *Cortex) updateFilterMapsHeads() { } func (s *Cortex) setupDiscovery() error { + s.startENRUpdater(s.p2pServer.LocalNode()) + dnsclient := dnsdisc.NewClient(dnsdisc.Config{}) if len(s.config.DiscoveryURLs) > 0 { iter, err := dnsclient.NewIterator(s.config.DiscoveryURLs...) diff --git a/ctxc/discovery.go b/ctxc/discovery.go index bbb6e8b8db..0b45c56bcc 100644 --- a/ctxc/discovery.go +++ b/ctxc/discovery.go @@ -38,7 +38,7 @@ func (e ctxcEntry) ENRKey() string { } // startCtxcEntryUpdate starts the ENR updater loop. -func (ctxc *Cortex) startCtxcEntryUpdate(ln *enode.LocalNode) { +func (ctxc *Cortex) startENRUpdater(ln *enode.LocalNode) { var newHead = make(chan core.ChainHeadEvent, 10) sub := ctxc.blockchain.SubscribeChainHeadEvent(newHead) diff --git a/go.mod b/go.mod index 047b845a92..0d395cad77 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.6.0 github.com/CortexFoundation/inference v1.0.2-0.20230307032835-9197d586a4e8 github.com/CortexFoundation/statik v0.0.0-20210315012922-8bb8a7b5dc66 - github.com/CortexFoundation/torrentfs v1.0.69-0.20250413152926-abb59313c23c + github.com/CortexFoundation/torrentfs v1.0.69-0.20250415112856-b1b452a24746 github.com/VictoriaMetrics/fastcache v1.12.2 github.com/arsham/figurine v1.3.0 github.com/aws/aws-sdk-go-v2 v1.36.3 @@ -206,7 +206,7 @@ require ( github.com/pion/transport/v2 v2.2.10 // indirect github.com/pion/transport/v3 v3.0.7 // indirect github.com/pion/turn/v4 v4.0.0 // indirect - github.com/pion/webrtc/v4 v4.0.14 // indirect + github.com/pion/webrtc/v4 v4.0.15 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_golang v1.22.0 // indirect diff --git a/go.sum b/go.sum index 57f372557e..e0d9de77d2 100644 --- a/go.sum +++ b/go.sum @@ -70,8 +70,8 @@ github.com/CortexFoundation/statik v0.0.0-20210315012922-8bb8a7b5dc66/go.mod h1: github.com/CortexFoundation/torrentfs v1.0.13-0.20200623060705-ce027f43f2f8/go.mod h1:Ma+tGhPPvz4CEZHaqEJQMOEGOfHeQBiAoNd1zyc/w3Q= github.com/CortexFoundation/torrentfs v1.0.14-0.20200703071639-3fcabcabf274/go.mod h1:qnb3YlIJmuetVBtC6Lsejr0Xru+1DNmDCdTqnwy7lhk= github.com/CortexFoundation/torrentfs v1.0.20-0.20200810031954-d36d26f82fcc/go.mod h1:N5BsicP5ynjXIi/Npl/SRzlJ630n1PJV2sRj0Z0t2HA= -github.com/CortexFoundation/torrentfs v1.0.69-0.20250413152926-abb59313c23c h1:lpJ1OrrVq0fAz9299pdKPZPfmqopKFO+OHpCJQ9xHbo= -github.com/CortexFoundation/torrentfs v1.0.69-0.20250413152926-abb59313c23c/go.mod h1:Lf7iaFiGPvExQiyPufsbQ8hs0XkKUunTLcp0r77/IaY= +github.com/CortexFoundation/torrentfs v1.0.69-0.20250415112856-b1b452a24746 h1:VP6BvIxVY1jh4UmvpJQqIzpmnYva25xVRevXHoPP/2M= +github.com/CortexFoundation/torrentfs v1.0.69-0.20250415112856-b1b452a24746/go.mod h1:Lf7iaFiGPvExQiyPufsbQ8hs0XkKUunTLcp0r77/IaY= github.com/CortexFoundation/wormhole v0.0.2-0.20241128010855-a23c88842cfa h1:46VAGWxOwpoLlPNcR9etAhK0NtT215skO9Wl4i14r4o= github.com/CortexFoundation/wormhole v0.0.2-0.20241128010855-a23c88842cfa/go.mod h1:ipzmPabDgzYKUbXkGVe2gTkBEp+MsDx6pXGiuYzmP6s= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= @@ -1037,8 +1037,8 @@ github.com/pion/turn/v4 v4.0.0 h1:qxplo3Rxa9Yg1xXDxxH8xaqcyGUtbHYw4QSCvmFWvhM= github.com/pion/turn/v4 v4.0.0/go.mod h1:MuPDkm15nYSklKpN8vWJ9W2M0PlyQZqYt1McGuxG7mA= github.com/pion/webrtc/v2 v2.2.7/go.mod h1:EfCuvKjzMgX4F/aSryRUC7L9o3u2N8WNUgnzd6wOO+8= github.com/pion/webrtc/v2 v2.2.9/go.mod h1:TcArPDphZIBtZ+mh8J/qOREyY3ca7ihQrenulOIvfPQ= -github.com/pion/webrtc/v4 v4.0.14 h1:nyds/sFRR+HvmWoBa6wrL46sSfpArE0qR883MBW96lg= -github.com/pion/webrtc/v4 v4.0.14/go.mod h1:R3+qTnQTS03UzwDarYecgioNf7DYgTsldxnCXB821Kk= +github.com/pion/webrtc/v4 v4.0.15 h1:DWuBtTHBa9rQNqyhW+jptkq6r3zdGqr1OQ4pa2Q+Ey4= +github.com/pion/webrtc/v4 v4.0.15/go.mod h1:RXf6sJ8FUX+qwF4+AwB+A3c2Y6WpuATRTe4L/fTWNa4= github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= diff --git a/node/node.go b/node/node.go index 23a4739e8c..c7d69768f1 100644 --- a/node/node.go +++ b/node/node.go @@ -273,7 +273,7 @@ func (n *Node) Start() error { var started []reflect.Type for kind, service := range services { // Start the next service, stopping all previous upon failure - if err := service.Start(running); err != nil { + if err := service.Start(); err != nil { for _, kind := range started { services[kind].Stop() } diff --git a/node/node_example_test.go b/node/node_example_test.go index 63f95abcb0..3f88882c6b 100644 --- a/node/node_example_test.go +++ b/node/node_example_test.go @@ -37,7 +37,7 @@ type SampleService struct{} func (s *SampleService) Protocols() []p2p.Protocol { return nil } func (s *SampleService) APIs() []rpc.API { return nil } -func (s *SampleService) Start(*p2p.Server) error { fmt.Println("Service starting..."); return nil } +func (s *SampleService) Start() error { fmt.Println("Service starting..."); return nil } func (s *SampleService) Stop() error { fmt.Println("Service stopping..."); return nil } func ExampleService() { diff --git a/node/node_test.go b/node/node_test.go index f5f9e6ed5f..108631b252 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -166,7 +166,7 @@ func TestServiceLifeCycle(t *testing.T) { id := id // Closure for the constructor constructor := func(*ServiceContext) (Service, error) { return &InstrumentedService{ - startHook: func(*p2p.Server) { started[id] = true }, + startHook: func() { started[id] = true }, stopHook: func() { stopped[id] = true }, }, nil } @@ -214,7 +214,7 @@ func TestServiceRestarts(t *testing.T) { running = false return &InstrumentedService{ - startHook: func(*p2p.Server) { + startHook: func() { if running { panic("already running") } @@ -266,7 +266,7 @@ func TestServiceConstructionAbortion(t *testing.T) { id := id // Closure for the constructor constructor := func(*ServiceContext) (Service, error) { return &InstrumentedService{ - startHook: func(*p2p.Server) { started[id] = true }, + startHook: func() { started[id] = true }, }, nil } if err := stack.Register(maker(constructor)); err != nil { @@ -317,7 +317,7 @@ func TestServiceStartupAbortion(t *testing.T) { id := id // Closure for the constructor constructor := func(*ServiceContext) (Service, error) { return &InstrumentedService{ - startHook: func(*p2p.Server) { started[id] = true }, + startHook: func() { started[id] = true }, stopHook: func() { stopped[id] = true }, }, nil } @@ -372,7 +372,7 @@ func TestServiceTerminationGuarantee(t *testing.T) { id := id // Closure for the constructor constructor := func(*ServiceContext) (Service, error) { return &InstrumentedService{ - startHook: func(*p2p.Server) { started[id] = true }, + startHook: func() { started[id] = true }, stopHook: func() { stopped[id] = true }, }, nil } diff --git a/node/service.go b/node/service.go index 92a0216bda..0f2d9310eb 100644 --- a/node/service.go +++ b/node/service.go @@ -111,7 +111,7 @@ type Service interface { // Start is called after all services have been constructed and the networking // layer was also initialized to spawn any goroutines required by the service. - Start(server *p2p.Server) error + Start() error // Stop terminates all goroutines belonging to the service, blocking until they // are all terminated. diff --git a/node/utils_test.go b/node/utils_test.go index f359f2850c..345efc28a8 100644 --- a/node/utils_test.go +++ b/node/utils_test.go @@ -31,7 +31,7 @@ type NoopService struct{} func (s *NoopService) Protocols() []p2p.Protocol { return nil } func (s *NoopService) APIs() []rpc.API { return nil } -func (s *NoopService) Start(*p2p.Server) error { return nil } +func (s *NoopService) Start() error { return nil } func (s *NoopService) Stop() error { return nil } func NewNoopService(*ServiceContext) (Service, error) { return new(NoopService), nil } @@ -55,7 +55,7 @@ type InstrumentedService struct { stop error protocolsHook func() - startHook func(*p2p.Server) + startHook func() stopHook func() } @@ -72,9 +72,9 @@ func (s *InstrumentedService) APIs() []rpc.API { return s.apis } -func (s *InstrumentedService) Start(server *p2p.Server) error { +func (s *InstrumentedService) Start() error { if s.startHook != nil { - s.startHook(server) + s.startHook() } return s.start } diff --git a/vendor/github.com/CortexFoundation/torrentfs/fs.go b/vendor/github.com/CortexFoundation/torrentfs/fs.go index 1553735587..a5a6fee2e8 100644 --- a/vendor/github.com/CortexFoundation/torrentfs/fs.go +++ b/vendor/github.com/CortexFoundation/torrentfs/fs.go @@ -332,19 +332,13 @@ func (fs *TorrentFS) Version() uint { // Start starts the data collection thread and the listening server of the dashboard. // Implements the node.Service interface. -func (fs *TorrentFS) Start(srvr *p2p.Server) (err error) { +func (fs *TorrentFS) Start() (err error) { log.Info("Fs server starting ... ...") if fs == nil || fs.monitor == nil { log.Warn("Storage fs init failed", "fs", fs) return } - // Figure out a max peers count based on the server limits - if srvr != nil { - log.Info("P2p net bounded") - fs.net = srvr - } - //log.Info("Started nas", "config", fs, "mode", fs.config.Mode, "version", params.ProtocolVersion, "queue", fs.tunnel.Len(), "peers", fs.Neighbors()) /*err = fs.db.Init() diff --git a/vendor/github.com/pion/webrtc/v4/.golangci.yml b/vendor/github.com/pion/webrtc/v4/.golangci.yml index 88cb4fbf9e..120faf29be 100644 --- a/vendor/github.com/pion/webrtc/v4/.golangci.yml +++ b/vendor/github.com/pion/webrtc/v4/.golangci.yml @@ -19,12 +19,16 @@ linters-settings: recommendations: - errors forbidigo: + analyze-types: true forbid: - ^fmt.Print(f|ln)?$ - ^log.(Panic|Fatal|Print)(f|ln)?$ - ^os.Exit$ - ^panic$ - ^print(ln)?$ + - p: ^testing.T.(Error|Errorf|Fatal|Fatalf|Fail|FailNow)$ + pkg: ^testing$ + msg: "use testify/assert instead" varnamelen: max-distance: 12 min-name-length: 2 @@ -127,9 +131,12 @@ issues: exclude-dirs-use-default: false exclude-rules: # Allow complex tests and examples, better to be self contained - - path: (examples|main\.go|_test\.go) + - path: (examples|main\.go) linters: + - gocognit - forbidigo + - path: _test\.go + linters: - gocognit # Allow forbidden identifiers in CLI commands diff --git a/vendor/github.com/pion/webrtc/v4/README.md b/vendor/github.com/pion/webrtc/v4/README.md index 5f5d9869f3..97bbe70f0e 100644 --- a/vendor/github.com/pion/webrtc/v4/README.md +++ b/vendor/github.com/pion/webrtc/v4/README.md @@ -8,8 +8,7 @@

Pion WebRTC Sourcegraph Widget - Slack Widget - Twitter Widget + join us on Discord Follow us on Bluesky Twitter Widget
GitHub Workflow Status @@ -26,7 +25,7 @@ Pion WebRTC v4.0.0 has been released! See the [release notes](https://github.com If you aren't able to upgrade yet check the [tags](https://github.com/pion/webrtc/tags) for the latest `v3` release. -We would love your feedback! Please create GitHub issues or join [the Slack channel](https://pion.ly/slack) to follow development and speak with the maintainers. +We would love your feedback! Please create GitHub issues or Join the [Discord](https://discord.gg/PngbdqpFbt) to follow development and speak with the maintainers. ----- @@ -42,7 +41,7 @@ We would love your feedback! Please create GitHub issues or join [the Slack chan **[GoDoc](https://pkg.go.dev/github.com/pion/webrtc/v4)** is an auto generated API reference. All our Public APIs are commented. -**[FAQ](https://github.com/pion/webrtc/wiki/FAQ)** has answers to common questions. If you have a question not covered please ask in [Slack](https://pion.ly/slack) we are always looking to expand it. +**[FAQ](https://github.com/pion/webrtc/wiki/FAQ)** has answers to common questions. If you have a question not covered please ask in [Discord](https://discord.gg/PngbdqpFbt) we are always looking to expand it. Now go build something awesome! Here are some **ideas** to get your creative juices flowing: * Send a video file to multiple browser in real time for perfectly synchronized movie watching. @@ -58,7 +57,7 @@ Learn the full details of ICE, SCTP, DTLS, SRTP, and how they work together to m resource if you are trying to debug. Learn the tools of the trade and how to approach WebRTC issues. This book is vendor agnostic and will not have any Pion specific information. -Pion has an active community on [Slack](https://pion.ly/slack). Please ask for help about anything, questions don't have to be Pion specific! +Pion has an active community on [Discord](https://discord.gg/PngbdqpFbt). Please ask for help about anything, questions don't have to be Pion specific! Come share your interesting project you are working on. We are here to support you. One of the maintainers of Pion [Sean-Der](https://github.com/sean-der) is available to help. Schedule at [siobud.com/meeting](https://siobud.com/meeting) @@ -126,9 +125,9 @@ If you are looking to get involved this is a great place to get started! We woul Work on Pion's congestion control and bandwidth estimation was funded through the [User-Operated Internet](https://nlnet.nl/useroperated/) fund, a fund established by [NLnet](https://nlnet.nl/) made possible by financial support from the [PKT Community](https://pkt.cash/)/[The Network Steward](https://pkt.cash/network-steward) and stichting [Technology Commons Trust](https://technologycommons.org/). ### Community -Pion has an active community on the [Slack](https://pion.ly/slack). +Pion has an active community on the [Discord](https://discord.gg/PngbdqpFbt). -Follow the [Pion Twitter](https://twitter.com/_pion) for project updates and important WebRTC news. +Follow the [Pion Bluesky](https://bsky.app/profile/pion.ly) or [Pion Twitter](https://twitter.com/_pion) for project updates and important WebRTC news. We are always looking to support **your projects**. Please reach out if you have something to build! If you need commercial support or don't want to use public methods you can contact us at [team@pion.ly](mailto:team@pion.ly) diff --git a/vendor/github.com/pion/webrtc/v4/icecandidate.go b/vendor/github.com/pion/webrtc/v4/icecandidate.go index fb40f33db3..db7af8409e 100644 --- a/vendor/github.com/pion/webrtc/v4/icecandidate.go +++ b/vendor/github.com/pion/webrtc/v4/icecandidate.go @@ -80,7 +80,8 @@ func newICECandidateFromICE(candidate ice.Candidate, sdpMid string, sdpMLineInde return newCandidate, nil } -func (c ICECandidate) toICE() (cand ice.Candidate, err error) { +// ToICE converts ICECandidate to ice.Candidate. +func (c ICECandidate) ToICE() (cand ice.Candidate, err error) { candidateID := c.statsID switch c.Typ { case ICECandidateTypeHost: @@ -216,7 +217,7 @@ func convertTypeFromICE(t ice.CandidateType) (ICECandidateType, error) { } func (c ICECandidate) String() string { - ic, err := c.toICE() + ic, err := c.ToICE() if err != nil { return fmt.Sprintf("%#v failed to convert to ICE: %s", c, err) } @@ -229,7 +230,7 @@ func (c ICECandidate) String() string { func (c ICECandidate) ToJSON() ICECandidateInit { candidateStr := "" - candidate, err := c.toICE() + candidate, err := c.ToICE() if err == nil { candidateStr = candidate.Marshal() } diff --git a/vendor/github.com/pion/webrtc/v4/icetransport.go b/vendor/github.com/pion/webrtc/v4/icetransport.go index a0a4654216..f8130e1001 100644 --- a/vendor/github.com/pion/webrtc/v4/icetransport.go +++ b/vendor/github.com/pion/webrtc/v4/icetransport.go @@ -298,7 +298,7 @@ func (t *ICETransport) SetRemoteCandidates(remoteCandidates []ICECandidate) erro } for _, c := range remoteCandidates { - i, err := c.toICE() + i, err := c.ToICE() if err != nil { return err } @@ -326,7 +326,7 @@ func (t *ICETransport) AddRemoteCandidate(remoteCandidate *ICECandidate) error { } if remoteCandidate != nil { - if candidate, err = remoteCandidate.toICE(); err != nil { + if candidate, err = remoteCandidate.ToICE(); err != nil { return err } } diff --git a/vendor/github.com/pion/webrtc/v4/mediaengine.go b/vendor/github.com/pion/webrtc/v4/mediaengine.go index 20a50ae405..170a72998d 100644 --- a/vendor/github.com/pion/webrtc/v4/mediaengine.go +++ b/vendor/github.com/pion/webrtc/v4/mediaengine.go @@ -20,42 +20,6 @@ import ( "github.com/pion/webrtc/v4/internal/fmtp" ) -const ( - // MimeTypeH264 H264 MIME type. - // Note: Matching should be case insensitive. - MimeTypeH264 = "video/H264" - // MimeTypeH265 H265 MIME type - // Note: Matching should be case insensitive. - MimeTypeH265 = "video/H265" - // MimeTypeOpus Opus MIME type - // Note: Matching should be case insensitive. - MimeTypeOpus = "audio/opus" - // MimeTypeVP8 VP8 MIME type - // Note: Matching should be case insensitive. - MimeTypeVP8 = "video/VP8" - // MimeTypeVP9 VP9 MIME type - // Note: Matching should be case insensitive. - MimeTypeVP9 = "video/VP9" - // MimeTypeAV1 AV1 MIME type - // Note: Matching should be case insensitive. - MimeTypeAV1 = "video/AV1" - // MimeTypeG722 G722 MIME type - // Note: Matching should be case insensitive. - MimeTypeG722 = "audio/G722" - // MimeTypePCMU PCMU MIME type - // Note: Matching should be case insensitive. - MimeTypePCMU = "audio/PCMU" - // MimeTypePCMA PCMA MIME type - // Note: Matching should be case insensitive. - MimeTypePCMA = "audio/PCMA" - // MimeTypeRTX RTX MIME type - // Note: Matching should be case insensitive. - MimeTypeRTX = "video/rtx" - // MimeTypeFlexFEC FEC MIME Type - // Note: Matching should be case insensitive. - MimeTypeFlexFEC = "video/flexfec" -) - type mediaEngineHeaderExtension struct { uri string isAudio, isVideo bool diff --git a/vendor/github.com/pion/webrtc/v4/mimetype.go b/vendor/github.com/pion/webrtc/v4/mimetype.go new file mode 100644 index 0000000000..9575f9eb1b --- /dev/null +++ b/vendor/github.com/pion/webrtc/v4/mimetype.go @@ -0,0 +1,46 @@ +// SPDX-FileCopyrightText: 2025 The Pion community +// SPDX-License-Identifier: MIT + +package webrtc + +const ( + // MimeTypeH264 H264 MIME type. + // Note: Matching should be case insensitive. + MimeTypeH264 = "video/H264" + // MimeTypeH265 H265 MIME type + // Note: Matching should be case insensitive. + MimeTypeH265 = "video/H265" + // MimeTypeOpus Opus MIME type + // Note: Matching should be case insensitive. + MimeTypeOpus = "audio/opus" + // MimeTypeVP8 VP8 MIME type + // Note: Matching should be case insensitive. + MimeTypeVP8 = "video/VP8" + // MimeTypeVP9 VP9 MIME type + // Note: Matching should be case insensitive. + MimeTypeVP9 = "video/VP9" + // MimeTypeAV1 AV1 MIME type + // Note: Matching should be case insensitive. + MimeTypeAV1 = "video/AV1" + // MimeTypeG722 G722 MIME type + // Note: Matching should be case insensitive. + MimeTypeG722 = "audio/G722" + // MimeTypePCMU PCMU MIME type + // Note: Matching should be case insensitive. + MimeTypePCMU = "audio/PCMU" + // MimeTypePCMA PCMA MIME type + // Note: Matching should be case insensitive. + MimeTypePCMA = "audio/PCMA" + // MimeTypeRTX RTX MIME type + // Note: Matching should be case insensitive. + MimeTypeRTX = "video/rtx" + // MimeTypeFlexFEC FEC MIME Type + // Note: Matching should be case insensitive. + MimeTypeFlexFEC = "video/flexfec" + // MimeTypeFlexFEC03 FlexFEC03 MIME Type + // Note: Matching should be case insensitive. + MimeTypeFlexFEC03 = "video/flexfec-03" + // MimeTypeUlpFEC UlpFEC MIME Type + // Note: Matching should be case insensitive. + MimeTypeUlpFEC = "video/ulpfec" +) diff --git a/vendor/github.com/pion/webrtc/v4/peerconnection.go b/vendor/github.com/pion/webrtc/v4/peerconnection.go index 99b182adb7..49a88927ee 100644 --- a/vendor/github.com/pion/webrtc/v4/peerconnection.go +++ b/vendor/github.com/pion/webrtc/v4/peerconnection.go @@ -2880,6 +2880,9 @@ func (pc *PeerConnection) generateMatchedSDP( } } + pc.sctpTransport.lock.Lock() + defer pc.sctpTransport.lock.Unlock() + var bundleGroup *string // If we are offering also include unmatched local transceivers if includeUnmatched { //nolint:nestif diff --git a/vendor/github.com/pion/webrtc/v4/rtpcodec.go b/vendor/github.com/pion/webrtc/v4/rtpcodec.go index 798d3093f3..d4733dbd07 100644 --- a/vendor/github.com/pion/webrtc/v4/rtpcodec.go +++ b/vendor/github.com/pion/webrtc/v4/rtpcodec.go @@ -155,6 +155,17 @@ func findRTXPayloadType(needle PayloadType, haystack []RTPCodecParameters) Paylo return PayloadType(0) } +// For now, only FlexFEC is supported. +func findFECPayloadType(haystack []RTPCodecParameters) PayloadType { + for _, c := range haystack { + if strings.Contains(c.RTPCodecCapability.MimeType, MimeTypeFlexFEC) { + return c.PayloadType + } + } + + return PayloadType(0) +} + func rtcpFeedbackIntersection(a, b []RTCPFeedback) (out []RTCPFeedback) { for _, aFeedback := range a { for _, bFeeback := range b { diff --git a/vendor/github.com/pion/webrtc/v4/rtpsender.go b/vendor/github.com/pion/webrtc/v4/rtpsender.go index 2052274149..27d27ab895 100644 --- a/vendor/github.com/pion/webrtc/v4/rtpsender.go +++ b/vendor/github.com/pion/webrtc/v4/rtpsender.go @@ -355,7 +355,7 @@ func (r *RTPSender) Send(parameters RTPSendParameters) error { parameters.Encodings[idx].FEC.SSRC, codec.PayloadType, findRTXPayloadType(codec.PayloadType, rtpParameters.Codecs), - 0, + findFECPayloadType(rtpParameters.Codecs), codec.RTPCodecCapability, parameters.HeaderExtensions, ) diff --git a/vendor/github.com/pion/webrtc/v4/sctptransport.go b/vendor/github.com/pion/webrtc/v4/sctptransport.go index 8477593c16..638ffcae02 100644 --- a/vendor/github.com/pion/webrtc/v4/sctptransport.go +++ b/vendor/github.com/pion/webrtc/v4/sctptransport.go @@ -430,3 +430,14 @@ func (r *SCTPTransport) association() *sctp.Association { return association } + +// BufferedAmount returns total amount (in bytes) of currently buffered user data. +func (r *SCTPTransport) BufferedAmount() int { + r.lock.Lock() + defer r.lock.Unlock() + if r.sctpAssociation == nil { + return 0 + } + + return r.sctpAssociation.BufferedAmount() +} diff --git a/vendor/github.com/pion/webrtc/v4/sdp.go b/vendor/github.com/pion/webrtc/v4/sdp.go index b41d3bfe40..fa10b6951f 100644 --- a/vendor/github.com/pion/webrtc/v4/sdp.go +++ b/vendor/github.com/pion/webrtc/v4/sdp.go @@ -302,7 +302,7 @@ func addCandidatesToMediaDescriptions( } for _, c := range candidates { - candidate, err := c.toICE() + candidate, err := c.ToICE() if err != nil { return err } diff --git a/vendor/modules.txt b/vendor/modules.txt index 2a1593dd78..946b131cc5 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -61,7 +61,7 @@ github.com/CortexFoundation/robot/backend # github.com/CortexFoundation/statik v0.0.0-20210315012922-8bb8a7b5dc66 ## explicit; go 1.16 github.com/CortexFoundation/statik -# github.com/CortexFoundation/torrentfs v1.0.69-0.20250413152926-abb59313c23c +# github.com/CortexFoundation/torrentfs v1.0.69-0.20250415112856-b1b452a24746 ## explicit; go 1.23.4 github.com/CortexFoundation/torrentfs github.com/CortexFoundation/torrentfs/backend @@ -969,7 +969,7 @@ github.com/pion/turn/v4/internal/client github.com/pion/turn/v4/internal/ipnet github.com/pion/turn/v4/internal/proto github.com/pion/turn/v4/internal/server -# github.com/pion/webrtc/v4 v4.0.14 +# github.com/pion/webrtc/v4 v4.0.15 ## explicit; go 1.20 github.com/pion/webrtc/v4 github.com/pion/webrtc/v4/internal/fmtp diff --git a/whisper/whisperv6/whisper.go b/whisper/whisperv6/whisper.go index bec6de9d86..4dcd659ac7 100644 --- a/whisper/whisperv6/whisper.go +++ b/whisper/whisperv6/whisper.go @@ -656,7 +656,7 @@ func (whisper *Whisper) Send(envelope *Envelope) error { // Start implements node.Service, starting the background data propagation thread // of the Whisper protocol. -func (whisper *Whisper) Start(*p2p.Server) error { +func (whisper *Whisper) Start() error { log.Info("Started whisper v." + ProtocolVersionStr) whisper.wg.Add(1) go whisper.update() diff --git a/whisper/whisperv6/whisper_test.go b/whisper/whisperv6/whisper_test.go index 2da36c316f..2bbecaf00a 100644 --- a/whisper/whisperv6/whisper_test.go +++ b/whisper/whisperv6/whisper_test.go @@ -454,7 +454,7 @@ func TestExpiry(t *testing.T) { w := New(&DefaultConfig) w.SetMinimumPowTest(0.0000001) defer w.SetMinimumPowTest(DefaultMinimumPoW) - w.Start(nil) + w.Start() defer w.Stop() params, err := generateMessageParams() @@ -520,7 +520,7 @@ func TestCustomization(t *testing.T) { w := New(&DefaultConfig) defer w.SetMinimumPowTest(DefaultMinimumPoW) defer w.SetMaxMessageSize(DefaultMaxMessageSize) - w.Start(nil) + w.Start() defer w.Stop() const smallPoW = 0.00001 @@ -613,7 +613,7 @@ func TestSymmetricSendCycle(t *testing.T) { w := New(&DefaultConfig) defer w.SetMinimumPowTest(DefaultMinimumPoW) defer w.SetMaxMessageSize(DefaultMaxMessageSize) - w.Start(nil) + w.Start() defer w.Stop() filter1, err := generateFilter(t, true) @@ -704,7 +704,7 @@ func TestSymmetricSendWithoutAKey(t *testing.T) { w := New(&DefaultConfig) defer w.SetMinimumPowTest(DefaultMinimumPoW) defer w.SetMaxMessageSize(DefaultMaxMessageSize) - w.Start(nil) + w.Start() defer w.Stop() filter, err := generateFilter(t, true) @@ -774,7 +774,7 @@ func TestSymmetricSendKeyMismatch(t *testing.T) { w := New(&DefaultConfig) defer w.SetMinimumPowTest(DefaultMinimumPoW) defer w.SetMaxMessageSize(DefaultMaxMessageSize) - w.Start(nil) + w.Start() defer w.Stop() filter, err := generateFilter(t, true)