feat(simnet): add SimNet protocol end-to-end support
- model: SimNet protocol fields + NormalizeSimnet; type+port protocol uniqueness - server config: OmnXT runtime config delivery via compatible() simnet case - credentials: derive per-user psk/key_id from subscription (pkg/simnet), no new table - subscription: adapter buildOmnxtSimnetConfigs + base64 buildOmnxtProtocolLinks + OmnXT SimNet application (migration 02161) - UA gating: hide experimental protocols from non first-party clients (download + JSON node-list) - admin: normalize simnet on create/update and on GET responses - tests: 21 simnet unit tests; full suite green
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package subscribe
|
||||
|
||||
import (
|
||||
"github.com/perfect-panel/server/internal/model/node"
|
||||
"github.com/perfect-panel/server/pkg/simnet"
|
||||
)
|
||||
|
||||
// filterExperimentalNodesForClient removes experimental-protocol nodes (simnet)
|
||||
// unless the client UA is a first-party client. Prevents generic clients from
|
||||
// rendering unusable simnet entries and from receiving simnet server material.
|
||||
// Keyword logic is shared via pkg/simnet (mirrors the Pro reference).
|
||||
func filterExperimentalNodesForClient(servers []*node.Node, userAgent string) []*node.Node {
|
||||
if simnet.ClientSupportsExperimental(userAgent) {
|
||||
return servers
|
||||
}
|
||||
filtered := make([]*node.Node, 0, len(servers))
|
||||
for _, n := range servers {
|
||||
if n == nil {
|
||||
continue
|
||||
}
|
||||
if simnet.IsExperimentalProtocol(n.Protocol) {
|
||||
continue
|
||||
}
|
||||
filtered = append(filtered, n)
|
||||
}
|
||||
return filtered
|
||||
}
|
||||
@@ -101,6 +101,11 @@ func (l *SubscribeLogic) Handler(req *types.SubscribeRequest) (resp *types.Subsc
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Experimental protocols (simnet) are only delivered to their own clients/SDK
|
||||
// (UA hits omnxt/slag/slaglab). Hide them from every other client so a
|
||||
// generic template never renders a broken/unusable node. Mirrors the Pro
|
||||
// reference FilterExperimentalNodesForClient.
|
||||
servers = filterExperimentalNodesForClient(servers, userAgent)
|
||||
a := adapter.NewAdapter(
|
||||
targetApp.SubscribeTemplate,
|
||||
adapter.WithServers(servers),
|
||||
@@ -109,6 +114,7 @@ func (l *SubscribeLogic) Handler(req *types.SubscribeRequest) (resp *types.Subsc
|
||||
adapter.WithOutputFormat(targetApp.OutputFormat),
|
||||
adapter.WithUserInfo(adapter.User{
|
||||
Password: userSubscribe.UUID,
|
||||
SubscribeID: userSubscribe.Id,
|
||||
ExpiredAt: userSubscribe.ExpireTime,
|
||||
Download: userSubscribe.Download,
|
||||
Upload: userSubscribe.Upload,
|
||||
|
||||
Reference in New Issue
Block a user