Apply inbounds on nodes via Xray with Reality settings and client sync.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+43
-4
@@ -99,6 +99,9 @@ func scanInbound(scanner interface {
|
||||
err := scanner.Scan(
|
||||
&in.ID, &in.ProfileID, &in.Tag, &in.ProtocolID, &in.ProtocolCode, &in.ProtocolName,
|
||||
&in.Port, &in.Network, &in.Security, &in.Listen, &in.Enabled, &in.SortOrder, &in.Remark,
|
||||
&in.Path, &in.Host, &in.SNI, &in.Fingerprint, &in.Flow, &in.ALPN,
|
||||
&in.RealityDest, &in.RealityServerNames, &in.RealityPrivateKey, &in.RealityPublicKey, &in.RealityShortID,
|
||||
&in.SSMethod, &in.Password,
|
||||
&in.CreatedAt, &in.UpdatedAt,
|
||||
)
|
||||
if err != nil {
|
||||
@@ -110,6 +113,9 @@ func scanInbound(scanner interface {
|
||||
const inboundColumns = `
|
||||
i.id, i.profile_id, i.tag, i.protocol_id, p.code, p.name,
|
||||
i.port, i.network, i.security, i.listen, i.enabled, i.sort_order, i.remark,
|
||||
i.path, i.host, i.sni, i.fingerprint, i.flow, i.alpn,
|
||||
i.reality_dest, i.reality_server_names, i.reality_private_key, i.reality_public_key, i.reality_short_id,
|
||||
i.ss_method, i.password,
|
||||
i.created_at, i.updated_at`
|
||||
|
||||
func ListInboundsByProfile(db *sql.DB, profileID uuid.UUID) ([]models.Inbound, error) {
|
||||
@@ -163,27 +169,57 @@ func CreateInbound(db *sql.DB, in *models.Inbound) error {
|
||||
if in.Listen == "" {
|
||||
in.Listen = "0.0.0.0"
|
||||
}
|
||||
if in.Fingerprint == "" {
|
||||
in.Fingerprint = "chrome"
|
||||
}
|
||||
if in.SSMethod == "" {
|
||||
in.SSMethod = "aes-128-gcm"
|
||||
}
|
||||
now := time.Now().UTC()
|
||||
in.CreatedAt = now
|
||||
in.UpdatedAt = now
|
||||
_, err := db.Exec(`
|
||||
INSERT INTO inbounds (
|
||||
id, profile_id, tag, protocol_id, port, network, security, listen, enabled, sort_order, remark, created_at, updated_at
|
||||
) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13)`,
|
||||
id, profile_id, tag, protocol_id, port, network, security, listen, enabled, sort_order, remark,
|
||||
path, host, sni, fingerprint, flow, alpn,
|
||||
reality_dest, reality_server_names, reality_private_key, reality_public_key, reality_short_id,
|
||||
ss_method, password, created_at, updated_at
|
||||
) VALUES (
|
||||
$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,
|
||||
$12,$13,$14,$15,$16,$17,
|
||||
$18,$19,$20,$21,$22,
|
||||
$23,$24,$25,$26
|
||||
)`,
|
||||
in.ID, in.ProfileID, in.Tag, in.ProtocolID, in.Port, in.Network, in.Security, in.Listen,
|
||||
in.Enabled, in.SortOrder, in.Remark, in.CreatedAt, in.UpdatedAt,
|
||||
in.Enabled, in.SortOrder, in.Remark,
|
||||
in.Path, in.Host, in.SNI, in.Fingerprint, in.Flow, in.ALPN,
|
||||
in.RealityDest, in.RealityServerNames, in.RealityPrivateKey, in.RealityPublicKey, in.RealityShortID,
|
||||
in.SSMethod, in.Password, in.CreatedAt, in.UpdatedAt,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
func UpdateInbound(db *sql.DB, in *models.Inbound) error {
|
||||
if in.Fingerprint == "" {
|
||||
in.Fingerprint = "chrome"
|
||||
}
|
||||
if in.SSMethod == "" {
|
||||
in.SSMethod = "aes-128-gcm"
|
||||
}
|
||||
_, err := db.Exec(`
|
||||
UPDATE inbounds SET
|
||||
tag = $2, protocol_id = $3, port = $4, network = $5, security = $6,
|
||||
listen = $7, enabled = $8, sort_order = $9, remark = $10, updated_at = NOW()
|
||||
listen = $7, enabled = $8, sort_order = $9, remark = $10,
|
||||
path = $11, host = $12, sni = $13, fingerprint = $14, flow = $15, alpn = $16,
|
||||
reality_dest = $17, reality_server_names = $18, reality_private_key = $19,
|
||||
reality_public_key = $20, reality_short_id = $21, ss_method = $22, password = $23,
|
||||
updated_at = NOW()
|
||||
WHERE id = $1`,
|
||||
in.ID, in.Tag, in.ProtocolID, in.Port, in.Network, in.Security,
|
||||
in.Listen, in.Enabled, in.SortOrder, in.Remark,
|
||||
in.Path, in.Host, in.SNI, in.Fingerprint, in.Flow, in.ALPN,
|
||||
in.RealityDest, in.RealityServerNames, in.RealityPrivateKey, in.RealityPublicKey, in.RealityShortID,
|
||||
in.SSMethod, in.Password,
|
||||
)
|
||||
return err
|
||||
}
|
||||
@@ -270,6 +306,9 @@ ORDER BY i.sort_order ASC, i.tag ASC`, nodeID, *n.ProfileID)
|
||||
if err := rows.Scan(
|
||||
&in.ID, &in.ProfileID, &in.Tag, &in.ProtocolID, &in.ProtocolCode, &in.ProtocolName,
|
||||
&in.Port, &in.Network, &in.Security, &in.Listen, &in.Enabled, &in.SortOrder, &in.Remark,
|
||||
&in.Path, &in.Host, &in.SNI, &in.Fingerprint, &in.Flow, &in.ALPN,
|
||||
&in.RealityDest, &in.RealityServerNames, &in.RealityPrivateKey, &in.RealityPublicKey, &in.RealityShortID,
|
||||
&in.SSMethod, &in.Password,
|
||||
&in.CreatedAt, &in.UpdatedAt, &in.NodeEnabled,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user