Initial commit

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-15 13:57:10 +08:00
co-authored by Claude Opus 5
commit 8679200f41
1897 changed files with 257900 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
package webg
import (
"errors"
"strings"
)
// AICallbackURL returns the externally reachable Web callback URL for AI jobs.
func AICallbackURL(path string) (string, error) {
if Conf == nil || strings.TrimSpace(Conf.URL.AiImageToVideoCallbackUrl) == "" {
return "", errors.New("ai image-to-video callback url is not configured")
}
return strings.TrimRight(strings.TrimSpace(Conf.URL.AiImageToVideoCallbackUrl), "/") + "/" + strings.TrimLeft(path, "/"), nil
}
+24
View File
@@ -0,0 +1,24 @@
package webg
import (
"os"
"91porn-server/common/elastic"
"91porn-server/common/log"
)
func InitElastic() {
opts := elastic.Options{
Address: []string{Conf.Elastic.VideoUrl},
MaxIdleConnsPerHost: 10,
IdleConnTimeout: 30,
UserName: Conf.Elastic.UserName,
PassWord: Conf.Elastic.PassWord,
}
c, err := elastic.InitElastic(opts)
if err != nil {
log.Error("startUp VideoES InitElastic error", log.E(err))
os.Exit(1)
}
VideoES = c
}
+28
View File
@@ -0,0 +1,28 @@
package webg
import (
"os"
"91porn-server/common/log"
"91porn-server/common/redis"
)
func InitRedis() {
r, err := redis.WithURL(Conf.Redis.URL)
if err != nil {
log.Error("startUp rUrl redis error", log.E(err))
os.Exit(1)
}
Redis = r
}
func RedisClose() error {
if Redis != nil {
if err := Redis.Close(); err != nil {
log.Error("Redis Redis Close Error", log.E(err))
return err
}
log.Info("Redis Redis Close OK")
}
return nil
}
+155
View File
@@ -0,0 +1,155 @@
package webg
import (
"91porn-server/common/constant"
"91porn-server/common/db"
"91porn-server/common/elastic"
"91porn-server/common/httputil"
"91porn-server/common/laosiji_app"
"91porn-server/common/redis"
"91porn-server/common/tg"
)
type StaticSource struct {
Portrait []string `json:"portrait"`
Cities []string `json:"cities"`
Names []string `json:"names"`
SysUser []uint64 `json:"sysUser"`
}
type GlobalConfig struct {
Base struct {
Port int64 `json:"port"`
PProf bool `json:"pprof"`
Env string `json:"env"`
JwtKey string `json:"jwtKey"`
WebJwtKey string `json:"webJwtKey"`
// 媒体分片(TS)鉴权签名密钥对象(含 keyVersion/key);未配置时回退内置默认(版本 default + constant.MediaSourceAuthKey)
TsAuth constant.TsAuthKeyConfig `json:"tsAuth"`
} `json:"base"`
Log struct {
Level string `json:"level"`
DisableStacktrace bool `json:"disableStacktrace"`
} `json:"log"`
Mongo struct {
VideoDbUrl string `json:"videoDbUrl"` //主数据库 存放强业务相关的数据
StatDbUrl string `json:"statDbUrl"` //统计数据库 存放统计 日志 渠道相关的数据
LogDbUrl string `json:"logDbUrl"` //日志数据库
} `json:"mongo"`
DaiChong struct {
AppID string `json:"appId"`
AppSecret string `json:"appSecret"`
Domain string `json:"domain"`
} `json:"daichong"`
Welfare struct {
AppID string `json:"appId"`
AppSecret string `json:"appSecret"`
} `json:"welfare"`
Redis struct {
URL string `json:"url"`
} `json:"redis"`
Im struct {
AppID string `json:"appId"`
AppName string `json:"appName"`
AppSecret string `json:"appSecret"`
} `json:"im"`
ImV2 struct {
BaseURL string `json:"baseUrl"`
DynamicConfigDomain string `json:"dynamicConfigDomain"`
SocketURL string `json:"socketUrl"`
MerchantCode string `json:"merchantCode"`
TenantCode string `json:"tenantCode"`
AppKey string `json:"appKey"`
ClientID string `json:"clientId"`
ClientSecret string `json:"clientSecret"`
} `json:"imv2"`
AdCenter struct {
ApiDomain string `json:"apiDomain"` // api地址
MerchantCode string `json:"merchantCode"` // 商户 code
AppCode string `json:"appCode"` // 应用 code
AesKey string `json:"aesKey"` // 数据解密KEY
} `json:"adCenter"`
Game struct {
URL string `json:"url"`
MercId int `json:"mercId"`
} `json:"game"`
URL struct {
ImCenterUrl string `json:"imCenterUrl"`
OriginUrl string `json:"originUrl"`
JH1BOriginUrl string `json:"jH1BOriginUrl"`
LaoSiJiOriginUrl string `json:"laoSiJiOriginUrl"`
LaoSiJiTSCdn string `json:"laoSiJiTSCdn"`
CdnUrl string `json:"cdnUrl"`
SearchUserUrl string `json:"searchUserUrl"`
UploadImgUrl string `json:"uploadImgUrl"`
UploadUrl string `json:"uploadUrl"`
SendSingleFile string `json:"sendSingleFile"`
SendBatchFile string `json:"sendBatchFile"`
PullFileUrl string `json:"pullFileUrl"`
PullFileInfo string `json:"pullFileInfo"`
FileInfoUrl string `json:"fileInfoUrl"`
PullSeriesUrl string `json:"pullSeriesUrl"`
LocalWebUrl string `json:"localWebUrl"`
LocalAppUrl string `json:"localAppUrl"`
HttpProxy string `json:"httpProxy"`
TransactionUrl string `json:"transactionUrl"` //支付下单地址
AiServer string `json:"aiServer"` //ai订单请求地址
AiUndressServer string `json:"aiUndressServer"` // AI图片脱衣服务地址
AiImageToVideoCallbackUrl string `json:"aiImageToVideoCallbackUrl"` // AI任务回调地址
} `json:"url"`
LSJ struct {
AppID string `json:"appId"`
APIKey string `json:"apiKey"`
APIUrl string `json:"apiUrl"`
ImageYuan string `json:"imageYuan"`
} `json:"lsj"`
Switch struct {
CdnOriginBaseOnLocal bool `json:"cdnOriginBaseOnLocal"` //是否开启cdn url,为文件服务源站
} `json:"switch"`
Elastic struct {
VideoUrl string `json:"videoUrl"`
UserName string `json:"userName"`
PassWord string `json:"passWord"`
} `json:"elastic"`
EnableIPWhite struct {
IsEnable bool `json:"isEnable"`
} `json:"enableIPWhite"`
MediaResourceDBCfg struct {
BaseUrl string `json:"baseUrl"` //域名
Merchat string `json:"merchat"` //商户号
Secret string `json:"secret"` //商户密钥
} `json:"mediaResourceDBCfg"` //媒体资源库配置
GodCommentAward int64 `json:"godCommentAward"` //神评奖励
Kafka struct {
Url string `yaml:"url"`
Group string `yaml:"group"`
} `yaml:"kafka"`
Customer struct {
Secret string `json:"secret"`
} `json:"customer"`
LaoSiJiAiMate laosiji_app.Config `json:"laoSiJiAiMate"`
SMS struct {
FengNiao struct {
Url string `json:"url"`
ChinaMercId string `json:"chinaMercId"`
ChinaSecret string `json:"chinaSecret"`
ChinaTmplId string `json:"chinaTmplId"`
InterMercId string `json:"interMercId"`
InterSecret string `json:"interSecret"`
InterTmplId string `json:"interTmplId"`
} `json:"fengNiao"`
} `json:"sms"`
}
var (
Conf *GlobalConfig
Redis *redis.Client
VideoDB *db.MongoDB
LogDB *db.MongoDB
StatDB *db.MongoDB
Bot *tg.Bot
ProxyCfg *httputil.ProxyCfg
ImAuth string //im token
VideoES *elastic.Client
Static *StaticSource
)