@@ -43,12 +43,12 @@
|
||||
- ✅ 默认收银员支持中英切换 助力出海需求
|
||||
- ✅ 快速迭代期 超多实用特性功能等你发现
|
||||
|
||||
## 🚀 安装部署
|
||||
## 🚀 安装部署
|
||||
|
||||
- 安装:[Docker](docs/docker/docker.md)・[Linux](docs/linux/install.md)・[1Panel](./docs/1panel/README.md)・[宝塔](./docs/bt_panel/README.md)
|
||||
- 对接:[独角数卡](docs/dujiaoka/dujiaoka.md)・[异次元](./docs/acg-faka.md)・[萌次元](./docs/mcy-shop.md)・[彩虹易支付](https://github.com/v03413/Epay-BEpusdt)
|
||||
- 开发:[API对接](docs/api/api.md)・[订单回调](docs/notify/readme.md)・[Python SDK](https://github.com/luoyanglang/bepusdt-python-sdk)
|
||||
- 其它:[https 配置](./docs/ssl.md)・[时钟同步](docs/linux/systemd-timesyncd.md)・[自定义收银台](./docs/template/README.md)
|
||||
- 安装:[Docker](docs/docker/docker.md)·[Linux](docs/linux/install.md)·[1Panel](./docs/1panel/README.md)·[宝塔](./docs/bt_panel/README.md)
|
||||
- 对接:[独角数卡](docs/dujiaoka/dujiaoka.md)·[异次元](./docs/acg-faka.md)·[萌次元](./docs/mcy-shop.md)·[彩虹易支付](https://github.com/v03413/Epay-BEpusdt)
|
||||
- 开发:[API对接](docs/api/api.md)·[订单回调](docs/notify/readme.md)·[Python SDK](https://github.com/luoyanglang/bepusdt-python-sdk)
|
||||
- 其它:[https 配置](./docs/ssl.md)·[时钟同步](docs/linux/systemd-timesyncd.md)·[自定义收银台](./docs/template/README.md)
|
||||
|
||||
## 🖼 功能截图
|
||||
|
||||
@@ -57,30 +57,29 @@
|
||||
|-------------------------------------------------|--------------------------------------------------|--------------------------------------------------------|
|
||||
| <img src=./docs/images/1.png alt=收银台 width=300> | <img src=./docs/images/2.png alt=后台订单 width=300> | <img src=./docs/images/3.png alt=Telegram通知 width=300> |
|
||||
|
||||
|
||||
## 🤔 常见问题
|
||||
## ❓ 常见问题
|
||||
|
||||
- [如何获取参数 admin_id](./docs/faq/admin_id.md)
|
||||
- [服务器宽带占用过大解释](./docs/faq/bandwidth.md)
|
||||
|
||||
## ⚠️ 特别注意
|
||||
## ⚠️ 重要提示
|
||||
|
||||
- 订单交易强依赖时间,请确保服务器时间准确性,否则可能导致订单异常!
|
||||
- 部分功能依赖网络,请确保服务器网络纯洁性,否则可能导致功能异常!
|
||||
- **订单交易强依赖时间**:请确保服务器时间准确,否则可能导致订单异常
|
||||
- **网络环境要求**:请确保服务器网络环境稳定,否则可能影响功能正常运行
|
||||
|
||||
## 🏝️ 交流反馈
|
||||
## 🏝️ 社区交流
|
||||
|
||||
- Telegram 群组:[https://t.me/BEpusdtChat](https://t.me/BEpusdtChat)
|
||||
- Telegram 频道:[https://t.me/BEpusdtChannel](https://t.me/BEpusdtChannel)
|
||||
- **Telegram 群组**:[https://t.me/BEpusdtChat](https://t.me/BEpusdtChat)
|
||||
- **Telegram 频道**:[https://t.me/BEpusdtChannel](https://t.me/BEpusdtChannel)
|
||||
|
||||
## 🙏 鸣谢
|
||||
## 🙏 致谢
|
||||
|
||||
- https://github.com/assimon/epusdt
|
||||
- [Epusdt](https://github.com/assimon/epusdt)
|
||||
|
||||
## 📢 声明
|
||||
## 📜 免责声明
|
||||
|
||||
- 本项目仅供个人学习研究使用,任何人或组织在使用过程中请符合当地的法律法规,否则产生的任何后果责任自负。
|
||||
本项目仅供个人学习研究使用。任何人或组织在使用过程中请符合当地的法律法规,否则产生的任何后果责任自负。
|
||||
|
||||
## 🌟 Stargazers over time
|
||||
## 🌟 Star 历史
|
||||
|
||||
[](https://starchart.cc/v03413/bepusdt)
|
||||
|
||||
@@ -54,6 +54,7 @@ func (Wallet) Add(ctx *gin.Context) {
|
||||
Name: strings.TrimSpace(req.Name),
|
||||
Remark: req.Remark,
|
||||
Address: strings.TrimSpace(req.Address),
|
||||
MatchAddr: strings.TrimSpace(req.Address),
|
||||
TradeType: req.TradeType,
|
||||
Status: model.WaStatusEnable,
|
||||
OtherNotify: model.WaOtherDisable,
|
||||
@@ -65,6 +66,11 @@ func (Wallet) Add(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 非大小写敏感的地址,统一转为小写存储
|
||||
if !model.AddrCaseSens(model.TradeType(wallet.TradeType)) {
|
||||
wallet.MatchAddr = strings.ToLower(wallet.MatchAddr)
|
||||
}
|
||||
|
||||
if err := model.Db.Create(&wallet).Error; err != nil {
|
||||
base.Error(ctx, err)
|
||||
|
||||
@@ -133,6 +139,7 @@ func (Wallet) Mod(ctx *gin.Context) {
|
||||
}
|
||||
if req.Address != nil {
|
||||
w.Address = strings.TrimSpace(*req.Address)
|
||||
w.MatchAddr = strings.TrimSpace(*req.Address)
|
||||
}
|
||||
if req.TradeType != nil {
|
||||
if !model.IsSupportedTradeType(model.TradeType(*req.TradeType)) {
|
||||
@@ -156,6 +163,11 @@ func (Wallet) Mod(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 非大小写敏感的地址,统一转为小写存储
|
||||
if !model.AddrCaseSens(model.TradeType(w.TradeType)) {
|
||||
w.MatchAddr = strings.ToLower(w.Address)
|
||||
}
|
||||
|
||||
if err := model.Db.Save(&w).Error; err != nil {
|
||||
base.Error(ctx, err)
|
||||
|
||||
|
||||
@@ -13,15 +13,16 @@ type Range struct {
|
||||
MaxAmount decimal.Decimal
|
||||
}
|
||||
type TradeTypeConf struct {
|
||||
Alias string // 类型别名,主要用户前端展示
|
||||
Network Network // 所属区块链网络
|
||||
Crypto Crypto // 币种类型
|
||||
Native bool // 是否原生币
|
||||
Contract string // 合约地址,原生币为空
|
||||
Decimal int32 // 小数位
|
||||
AmountRange Range // 合法数额范围;这里特指则扫块时[数额范围],目前偷懒全部写死一个大概合理的范围,后面有问题再说...
|
||||
ExplorerFmt string // 区块浏览器交易链接格式化字符串,%s 位置替换为交易哈希
|
||||
EndpointKey ConfKey // RPC 端点配置键
|
||||
Alias string // 类型别名,主要用户前端展示
|
||||
Network Network // 所属区块链网络
|
||||
Crypto Crypto // 币种类型
|
||||
Native bool // 是否原生币
|
||||
Contract string // 合约地址,原生币为空
|
||||
Decimal int32 // 小数位
|
||||
AmountRange Range // 合法数额范围;这里特指则扫块时[数额范围],目前偷懒全部写死一个大概合理的范围,后面有问题再说...
|
||||
ExplorerFmt string // 区块浏览器交易链接格式化字符串,%s 位置替换为交易哈希
|
||||
EndpointKey ConfKey // RPC 端点配置键
|
||||
AddrCaseSens bool // 钱包地址是否大小写敏感,如果为 false 则会统一转为小写比较
|
||||
}
|
||||
|
||||
const (
|
||||
|
||||
@@ -27,8 +27,13 @@ func Init(path string) error {
|
||||
return fmt.Errorf("创建数据库目录失败:%w", err)
|
||||
}
|
||||
|
||||
dsn := fmt.Sprintf("%s?cache=shared&mode=rwc&_pragma=cache_size(-18888)&_pragma=journal_mode(WAL)&_pragma=busy_timeout(5000)", path)
|
||||
|
||||
dsn := fmt.Sprintf("%s?cache=shared&mode=rwc"+
|
||||
"&_pragma=cache_size(-32000)"+ // 32MB 缓存,平衡内存占用
|
||||
"&_pragma=journal_mode(WAL)"+
|
||||
"&_pragma=busy_timeout(8000)"+ // 8 秒超时,兼顾慢速磁盘
|
||||
"&_pragma=synchronous(NORMAL)"+ // NORMAL 模式,性能与安全平衡
|
||||
"&_pragma=wal_autocheckpoint(1500)", // 适中的 checkpoint 频率
|
||||
path)
|
||||
Db, err = gorm.Open(sqlite.Open(dsn), &gorm.Config{})
|
||||
if err != nil {
|
||||
|
||||
|
||||
@@ -39,14 +39,15 @@ var registry = map[TradeType]TradeTypeConf{
|
||||
EndpointKey: RpcEndpointPlasma,
|
||||
},
|
||||
UsdtTrc20: {
|
||||
Alias: "USDT・TRC20",
|
||||
Network: conf.Tron,
|
||||
Crypto: USDT,
|
||||
Contract: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", // 占位,目前实际没使用
|
||||
Decimal: conf.UsdtTronDecimals,
|
||||
AmountRange: usdGeneralRange,
|
||||
ExplorerFmt: "https://tronscan.org/#/transaction/%s",
|
||||
EndpointKey: RpcEndpointTron,
|
||||
Alias: "USDT・TRC20",
|
||||
Network: conf.Tron,
|
||||
Crypto: USDT,
|
||||
Contract: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", // 占位,目前实际没使用
|
||||
Decimal: conf.UsdtTronDecimals,
|
||||
AmountRange: usdGeneralRange,
|
||||
ExplorerFmt: "https://tronscan.org/#/transaction/%s",
|
||||
EndpointKey: RpcEndpointTron,
|
||||
AddrCaseSens: true,
|
||||
},
|
||||
UsdtErc20: {
|
||||
Alias: "USDT・ERC20",
|
||||
@@ -89,14 +90,15 @@ var registry = map[TradeType]TradeTypeConf{
|
||||
EndpointKey: RpcEndpointXlayer,
|
||||
},
|
||||
UsdtSolana: {
|
||||
Alias: "USDT・Solana",
|
||||
Network: conf.Solana,
|
||||
Crypto: USDT,
|
||||
Contract: conf.UsdtSolana,
|
||||
Decimal: conf.UsdtSolanaDecimals,
|
||||
AmountRange: usdGeneralRange,
|
||||
ExplorerFmt: "https://solscan.io/tx/%s",
|
||||
EndpointKey: RpcEndpointSolana,
|
||||
Alias: "USDT・Solana",
|
||||
Network: conf.Solana,
|
||||
Crypto: USDT,
|
||||
Contract: conf.UsdtSolana,
|
||||
Decimal: conf.UsdtSolanaDecimals,
|
||||
AmountRange: usdGeneralRange,
|
||||
ExplorerFmt: "https://solscan.io/tx/%s",
|
||||
EndpointKey: RpcEndpointSolana,
|
||||
AddrCaseSens: true,
|
||||
},
|
||||
UsdtPolygon: {
|
||||
Alias: "USDT・Polygon",
|
||||
@@ -179,24 +181,26 @@ var registry = map[TradeType]TradeTypeConf{
|
||||
EndpointKey: RpcEndpointBase,
|
||||
},
|
||||
UsdcTrc20: {
|
||||
Alias: "USDC・TRC20",
|
||||
Network: conf.Tron,
|
||||
Crypto: USDC,
|
||||
Contract: "TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8", // 占位,目前实际没使用
|
||||
Decimal: conf.UsdcTronDecimals,
|
||||
AmountRange: usdGeneralRange,
|
||||
ExplorerFmt: "https://tronscan.org/#/transaction/%s",
|
||||
EndpointKey: RpcEndpointTron,
|
||||
Alias: "USDC・TRC20",
|
||||
Network: conf.Tron,
|
||||
Crypto: USDC,
|
||||
Contract: "TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8", // 占位,目前实际没使用
|
||||
Decimal: conf.UsdcTronDecimals,
|
||||
AmountRange: usdGeneralRange,
|
||||
ExplorerFmt: "https://tronscan.org/#/transaction/%s",
|
||||
EndpointKey: RpcEndpointTron,
|
||||
AddrCaseSens: true,
|
||||
},
|
||||
UsdcSolana: {
|
||||
Alias: "USDC・Solana",
|
||||
Network: conf.Solana,
|
||||
Crypto: USDC,
|
||||
Contract: conf.UsdcSolana,
|
||||
Decimal: conf.UsdcSolanaDecimals,
|
||||
AmountRange: usdGeneralRange,
|
||||
ExplorerFmt: "https://solscan.io/tx/%s",
|
||||
EndpointKey: RpcEndpointSolana,
|
||||
Alias: "USDC・Solana",
|
||||
Network: conf.Solana,
|
||||
Crypto: USDC,
|
||||
Contract: conf.UsdcSolana,
|
||||
Decimal: conf.UsdcSolanaDecimals,
|
||||
AmountRange: usdGeneralRange,
|
||||
ExplorerFmt: "https://solscan.io/tx/%s",
|
||||
EndpointKey: RpcEndpointSolana,
|
||||
AddrCaseSens: true,
|
||||
},
|
||||
UsdcAptos: {
|
||||
Alias: "USDC・Aptos",
|
||||
@@ -218,8 +222,9 @@ var registry = map[TradeType]TradeTypeConf{
|
||||
MinAmount: decimal.NewFromFloat(0.1),
|
||||
MaxAmount: decimal.NewFromFloat(1000000),
|
||||
},
|
||||
ExplorerFmt: "https://tronscan.org/#/transaction/%s",
|
||||
EndpointKey: RpcEndpointTron,
|
||||
ExplorerFmt: "https://tronscan.org/#/transaction/%s",
|
||||
EndpointKey: RpcEndpointTron,
|
||||
AddrCaseSens: true,
|
||||
},
|
||||
EthereumEth: {
|
||||
Alias: "Ethereum・Eth",
|
||||
@@ -377,3 +382,12 @@ func GetSupportCrypto() map[Crypto]CoinId {
|
||||
|
||||
return supportCrypto
|
||||
}
|
||||
|
||||
func AddrCaseSens(t TradeType) bool {
|
||||
if c, ok := registry[t]; ok {
|
||||
|
||||
return c.AddrCaseSens
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/shopspring/decimal"
|
||||
@@ -164,6 +165,9 @@ func BuildTrade(p OrderParams) (Trade, error) {
|
||||
var wallet = GetAvailableAddress(p.TradeType)
|
||||
if p.Address != "" {
|
||||
wallet = []string{p.Address}
|
||||
if !AddrCaseSens(p.TradeType) { // 交易类型不区分大小写,统一转小写;这个地址最后的交易匹配要用到,千万不能错
|
||||
wallet = []string{strings.ToLower(p.Address)}
|
||||
}
|
||||
}
|
||||
|
||||
if len(wallet) == 0 {
|
||||
|
||||
@@ -15,7 +15,8 @@ type Wallet struct {
|
||||
Id
|
||||
Name string `gorm:"column:name;type:varchar(32);not null;default:-';comment:名称" json:"name"`
|
||||
Status uint8 `gorm:"column:status;type:tinyint(1);not null;default:1;comment:地址状态" json:"status"`
|
||||
Address string `gorm:"column:address;type:varchar(64);not null;uniqueIndex:idx_address;comment:钱包地址" json:"address"`
|
||||
Address string `gorm:"column:address;type:varchar(64);not null;index;comment:钱包地址" json:"address"`
|
||||
MatchAddr string `gorm:"column:match_addr;type:varchar(64);not null;uniqueIndex:idx_address;comment:匹配地址" json:"match_addr"`
|
||||
TradeType string `gorm:"column:trade_type;type:varchar(20);not null;uniqueIndex:idx_address;comment:交易类型" json:"trade_type"`
|
||||
OtherNotify uint8 `gorm:"column:other_notify;type:tinyint(1);not null;default:0;comment:其它通知" json:"other_notify"`
|
||||
Remark string `gorm:"column:remark;type:varchar(255);not null;default:'';comment:备注" json:"remark"`
|
||||
@@ -97,7 +98,7 @@ func GetAvailableAddress(t TradeType) []string {
|
||||
|
||||
wallets := make([]string, 0, len(rows))
|
||||
for _, w := range rows {
|
||||
wallets = append(wallets, w.Address)
|
||||
wallets = append(wallets, w.MatchAddr)
|
||||
}
|
||||
|
||||
return wallets
|
||||
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
"github.com/v03413/bepusdt/app/log"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
)
|
||||
|
||||
type aptos struct {
|
||||
@@ -25,6 +26,7 @@ type aptos struct {
|
||||
versionInitStartOffset int64
|
||||
lastVersion int64
|
||||
versionQueue *chanx.UnboundedChan[version]
|
||||
client *http.Client
|
||||
}
|
||||
|
||||
type version struct {
|
||||
@@ -60,6 +62,7 @@ func newAptos() aptos {
|
||||
versionInitStartOffset: -100 * 500,
|
||||
lastVersion: 0,
|
||||
versionQueue: chanx.NewUnboundedChan[version](context.Background(), 30),
|
||||
client: utils.NewHttpClient(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +73,7 @@ func (a *aptos) versionRoll(ctx context.Context) {
|
||||
}
|
||||
|
||||
req, _ := http.NewRequestWithContext(ctx, "GET", model.Endpoint(conf.Aptos)+"/v1", nil)
|
||||
resp, err := client.Do(req)
|
||||
resp, err := a.client.Do(req)
|
||||
if err != nil {
|
||||
log.Task.Warn("aptos versionRoll Error sending request:", err)
|
||||
|
||||
@@ -191,7 +194,7 @@ func (a *aptos) versionParse(n any) {
|
||||
var url = fmt.Sprintf("%sv1/transactions?start=%d&limit=%d", model.Endpoint(conf.Aptos), p.Start, p.Limit)
|
||||
|
||||
conf.RecordSuccess(net)
|
||||
resp, err := client.Get(url)
|
||||
resp, err := a.client.Get(url)
|
||||
if err != nil {
|
||||
conf.RecordFailure(net)
|
||||
log.Task.Warn("versionParse Error sending request:", err)
|
||||
@@ -390,7 +393,7 @@ func (a *aptos) tradeConfirmHandle(ctx context.Context) {
|
||||
|
||||
var handle = func(o model.Order) {
|
||||
req, _ := http.NewRequestWithContext(ctx, "GET", model.Endpoint(conf.Aptos)+"v1/transactions/by_hash/"+o.RefHash, nil)
|
||||
resp, err := client.Do(req)
|
||||
resp, err := a.client.Do(req)
|
||||
if err != nil {
|
||||
log.Task.Warn("aptos tradeConfirmHandle Error sending request:", err)
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"github.com/smallnest/chanx"
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
)
|
||||
|
||||
func arbitrumInit() {
|
||||
@@ -16,6 +17,7 @@ func arbitrumInit() {
|
||||
InitStartOffset: -600,
|
||||
ConfirmedOffset: 40,
|
||||
},
|
||||
Client: utils.NewHttpClient(),
|
||||
blockScanQueue: chanx.NewUnboundedChan[evmBlock](ctx, 30),
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"github.com/smallnest/chanx"
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
)
|
||||
|
||||
func baseInit() {
|
||||
@@ -16,6 +17,7 @@ func baseInit() {
|
||||
InitStartOffset: -600,
|
||||
ConfirmedOffset: 40,
|
||||
},
|
||||
Client: utils.NewHttpClient(),
|
||||
blockScanQueue: chanx.NewUnboundedChan[evmBlock](ctx, 30),
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/smallnest/chanx"
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
)
|
||||
|
||||
func bscInit() {
|
||||
@@ -22,6 +23,7 @@ func bscInit() {
|
||||
Decimal: conf.BscBnbDecimals,
|
||||
TradeType: model.BscBnb,
|
||||
},
|
||||
Client: utils.NewHttpClient(),
|
||||
blockScanQueue: chanx.NewUnboundedChan[evmBlock](ctx, 30),
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/smallnest/chanx"
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
)
|
||||
|
||||
func ethInit() {
|
||||
@@ -22,6 +23,7 @@ func ethInit() {
|
||||
TradeType: model.EthereumEth,
|
||||
Decimal: conf.EthereumEthDecimals,
|
||||
},
|
||||
Client: utils.NewHttpClient(),
|
||||
blockScanQueue: chanx.NewUnboundedChan[evmBlock](ctx, 30),
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ const (
|
||||
)
|
||||
|
||||
var chainBlockNum sync.Map
|
||||
var client = &http.Client{Timeout: time.Second * 30}
|
||||
|
||||
type block struct {
|
||||
InitStartOffset int64 // 首次偏移量,第一次启动时,区块高度需要叠加此值,设置为负值可解决部分已创建但未超时(未扫描)的订单问题
|
||||
@@ -48,6 +47,7 @@ type evm struct {
|
||||
Network string
|
||||
Block block
|
||||
Native evmNative
|
||||
Client *http.Client
|
||||
blockScanQueue *chanx.UnboundedChan[evmBlock]
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ func (e *evm) blockRoll(ctx context.Context) {
|
||||
}
|
||||
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
resp, err := client.Do(req)
|
||||
resp, err := e.Client.Do(req)
|
||||
if err != nil {
|
||||
log.Task.Warn("Error sending request:", err)
|
||||
|
||||
@@ -141,7 +141,7 @@ func (e *evm) blockInitOffset(now, offset int64) int64 {
|
||||
}
|
||||
|
||||
func (e *evm) blockDispatch(ctx context.Context) {
|
||||
p, err := ants.NewPoolWithFunc(2, e.getBlockByNumber)
|
||||
p, err := ants.NewPoolWithFunc(3, e.getBlockByNumber)
|
||||
if err != nil {
|
||||
log.Task.Warn("Error creating pool:", err)
|
||||
|
||||
@@ -158,7 +158,7 @@ func (e *evm) blockDispatch(ctx context.Context) {
|
||||
if err := p.Invoke(n); err != nil {
|
||||
e.blockScanQueue.In <- n
|
||||
|
||||
log.Task.Warn("evmBlockDispatch Error invoking process block:", err)
|
||||
log.Task.Warn("Evm Block Dispatch Error invoking process block:", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -188,7 +188,7 @@ func (e *evm) getBlockByNumber(a any) {
|
||||
}
|
||||
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
resp, err := client.Do(req)
|
||||
resp, err := e.Client.Do(req)
|
||||
if err != nil {
|
||||
conf.RecordFailure(e.Network)
|
||||
e.blockScanQueue.In <- b
|
||||
@@ -296,7 +296,7 @@ func (e *evm) parseNativeTransfer(array []gjson.Result, num int64, timestamp tim
|
||||
func (e *evm) parseEventTransfer(b evmBlock, timestamp map[string]time.Time) ([]transfer, error) {
|
||||
transfers := make([]transfer, 0)
|
||||
post := []byte(fmt.Sprintf(`{"jsonrpc":"2.0","method":"eth_getLogs","params":[{"fromBlock":"0x%x","toBlock":"0x%x","topics":["%s"]}],"id":1}`, b.From, b.To, evmTransferEvent))
|
||||
resp, err := client.Post(e.rpcEndpoint(), "application/json", bytes.NewBuffer(post))
|
||||
resp, err := e.Client.Post(e.rpcEndpoint(), "application/json", bytes.NewBuffer(post))
|
||||
if err != nil {
|
||||
|
||||
return transfers, errors.Join(errors.New("eth_getLogs Post Error"), err)
|
||||
@@ -379,7 +379,7 @@ func (e *evm) tradeConfirmHandle(ctx context.Context) {
|
||||
}
|
||||
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
resp, err := client.Do(req)
|
||||
resp, err := e.Client.Do(req)
|
||||
if err != nil {
|
||||
log.Task.Warn("evm tradeConfirmHandle Error sending request:", err)
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"github.com/smallnest/chanx"
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
)
|
||||
|
||||
func plasmaInit() {
|
||||
@@ -16,6 +17,7 @@ func plasmaInit() {
|
||||
InitStartOffset: -600,
|
||||
ConfirmedOffset: 40,
|
||||
},
|
||||
Client: utils.NewHttpClient(),
|
||||
blockScanQueue: chanx.NewUnboundedChan[evmBlock](ctx, 30),
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"github.com/smallnest/chanx"
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
)
|
||||
|
||||
func polygonInit() {
|
||||
@@ -16,6 +17,7 @@ func polygonInit() {
|
||||
InitStartOffset: -600,
|
||||
ConfirmedOffset: 40,
|
||||
},
|
||||
Client: utils.NewHttpClient(),
|
||||
blockScanQueue: chanx.NewUnboundedChan[evmBlock](ctx, 30),
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
"github.com/v03413/bepusdt/app/log"
|
||||
"github.com/v03413/bepusdt/app/model"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
)
|
||||
|
||||
// 参考文档
|
||||
@@ -31,6 +32,7 @@ type solana struct {
|
||||
slotInitStartOffset int64
|
||||
lastSlotNum int64
|
||||
slotQueue *chanx.UnboundedChan[int64]
|
||||
client *http.Client
|
||||
}
|
||||
|
||||
type solanaTokenOwner struct {
|
||||
@@ -53,6 +55,7 @@ func newSolana() solana {
|
||||
slotInitStartOffset: -600,
|
||||
lastSlotNum: 0,
|
||||
slotQueue: chanx.NewUnboundedChan[int64](context.Background(), 30),
|
||||
client: utils.NewHttpClient(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +68,7 @@ func (s *solana) slotRoll(ctx context.Context) {
|
||||
req, err := http.NewRequestWithContext(ctx, "POST", model.Endpoint(conf.Solana), bytes.NewBuffer([]byte(`{"jsonrpc":"2.0","id":1,"method":"getSlot"}`)))
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
resp, err := client.Do(req)
|
||||
resp, err := s.client.Do(req)
|
||||
if err != nil {
|
||||
log.Task.Warn("slotRoll Error sending request:", err)
|
||||
|
||||
@@ -169,7 +172,7 @@ func (s *solana) slotParse(n any) {
|
||||
network := conf.Solana
|
||||
|
||||
conf.RecordSuccess(network)
|
||||
resp, err := client.Post(model.Endpoint(conf.Solana), "application/json", bytes.NewBuffer(post))
|
||||
resp, err := s.client.Post(model.Endpoint(conf.Solana), "application/json", bytes.NewBuffer(post))
|
||||
if err != nil {
|
||||
conf.RecordFailure(network)
|
||||
log.Task.Warn("slotParse Error sending request:", err)
|
||||
@@ -348,7 +351,7 @@ func (s *solana) tradeConfirmHandle(ctx context.Context) {
|
||||
var handle = func(o model.Order) {
|
||||
post := []byte(fmt.Sprintf(`{"jsonrpc":"2.0","id":1,"method":"getSignatureStatuses","params":[["%s"],{"searchTransactionHistory":true}]}`, o.RefHash))
|
||||
req, _ := http.NewRequestWithContext(ctx, "POST", model.Endpoint(conf.Solana), bytes.NewBuffer(post))
|
||||
resp, err := client.Do(req)
|
||||
resp, err := s.client.Do(req)
|
||||
if err != nil {
|
||||
log.Task.Warn("solana tradeConfirmHandle Error sending request:", err)
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ func notOrderTransferHandle(ctx context.Context) {
|
||||
model.Db.Where("other_notify = ?", model.WaOtherEnable).Find(&was)
|
||||
for _, wa := range was {
|
||||
for _, t := range batch {
|
||||
if t.RecvAddress != wa.Address && t.FromAddress != wa.Address {
|
||||
if t.RecvAddress != wa.MatchAddr && t.FromAddress != wa.MatchAddr {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -217,21 +217,16 @@ func markFinalConfirmed(o model.Order) {
|
||||
func getAllWaitingOrders() map[string][]model.Order {
|
||||
var tradeOrders = model.GetOrderByStatus(model.OrderStatusWaiting)
|
||||
var data = make(map[string][]model.Order)
|
||||
for _, order := range tradeOrders {
|
||||
if time.Now().Unix() >= order.ExpiredAt.Unix() { // 订单过期
|
||||
order.SetExpired()
|
||||
notify.Bepusdt(order)
|
||||
for _, t := range tradeOrders {
|
||||
if time.Now().Unix() >= t.ExpiredAt.Unix() { // 订单过期
|
||||
t.SetExpired()
|
||||
notify.Bepusdt(t)
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
if order.TradeType == model.UsdtPolygon {
|
||||
|
||||
order.Address = strings.ToLower(order.Address)
|
||||
}
|
||||
|
||||
key := order.Address + string(order.TradeType)
|
||||
data[key] = append(data[key], order)
|
||||
key := t.Address + string(t.TradeType)
|
||||
data[key] = append(data[key], t)
|
||||
}
|
||||
|
||||
return data
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
"github.com/v03413/tronprotocol/api"
|
||||
"github.com/v03413/tronprotocol/core"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/connectivity"
|
||||
)
|
||||
|
||||
var gasFreeUsdtTokenAddress = []byte{0xa6, 0x14, 0xf8, 0x03, 0xb6, 0xfd, 0x78, 0x09, 0x86, 0xa4, 0x2c, 0x78, 0xec, 0x9c, 0x7f, 0x77, 0xe6, 0xde, 0xd1, 0x3c}
|
||||
@@ -35,6 +36,8 @@ type tron struct {
|
||||
blockInitStartOffset int64
|
||||
lastBlockNum int64
|
||||
blockScanQueue *chanx.UnboundedChan[int64]
|
||||
conn map[string]*grpc.ClientConn
|
||||
connMu sync.RWMutex
|
||||
}
|
||||
|
||||
var tr tron
|
||||
@@ -52,6 +55,7 @@ func newTron() tron {
|
||||
blockInitStartOffset: -400, // 大概为过去20分钟的区块高度
|
||||
lastBlockNum: 0,
|
||||
blockScanQueue: chanx.NewUnboundedChan[int64](context.Background(), 30),
|
||||
conn: make(map[string]*grpc.ClientConn),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,19 +65,15 @@ func (t *tron) blockRoll(context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
conn, err := utils.NewTronGrpcClient(model.Endpoint(conf.Tron), model.GetK(model.RpcEndpointTronGridApiKey))
|
||||
conn, err := t.client()
|
||||
if err != nil {
|
||||
log.Task.Error("grpc.NewClient", err)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
defer conn.Close()
|
||||
|
||||
var client = api.NewWalletClient(conn)
|
||||
|
||||
var ctx, cancel = context.WithTimeout(context.Background(), time.Second*15)
|
||||
block, err1 := client.GetNowBlock2(ctx, nil)
|
||||
block, err1 := api.NewWalletClient(conn).GetNowBlock2(ctx, nil)
|
||||
defer cancel()
|
||||
|
||||
if err1 != nil {
|
||||
@@ -106,7 +106,7 @@ func (t *tron) blockRoll(context.Context) {
|
||||
}
|
||||
|
||||
func (t *tron) blockDispatch(context.Context) {
|
||||
p, err := ants.NewPoolWithFunc(3, t.blockParse)
|
||||
p, err := ants.NewPoolWithFunc(2, t.blockParse)
|
||||
if err != nil {
|
||||
log.Task.Warn("Error creating pool:", err)
|
||||
|
||||
@@ -129,24 +129,21 @@ func (t *tron) blockParse(n any) {
|
||||
|
||||
var conn *grpc.ClientConn
|
||||
var err error
|
||||
if conn, err = utils.NewTronGrpcClient(model.Endpoint(conf.Tron), model.GetK(model.RpcEndpointTronGridApiKey)); err != nil {
|
||||
if conn, err = t.client(); err != nil {
|
||||
log.Task.Error("grpc.NewClient", err)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
defer conn.Close()
|
||||
var client = api.NewWalletClient(conn)
|
||||
|
||||
conf.RecordSuccess(conf.Tron)
|
||||
|
||||
var ctx, cancel = context.WithTimeout(context.Background(), time.Second*5)
|
||||
bok, err2 := client.GetBlockByNum2(ctx, &api.NumberMessage{Num: num})
|
||||
bok, err2 := api.NewWalletClient(conn).GetBlockByNum2(ctx, &api.NumberMessage{Num: num})
|
||||
cancel()
|
||||
if err2 != nil {
|
||||
conf.RecordFailure(conf.Tron)
|
||||
t.blockScanQueue.In <- num
|
||||
log.Task.Warn("GetBlockByNum2 Error", err2)
|
||||
log.Task.Warn("GetBlockByNum2 ", err2)
|
||||
|
||||
return
|
||||
}
|
||||
@@ -233,6 +230,10 @@ func (t *tron) blockParse(n any) {
|
||||
}
|
||||
|
||||
data := foo.GetData()
|
||||
if len(data) < 4 {
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
// Gas Free 钱包 合约授权转账
|
||||
if bytes.Equal(foo.OwnerAddress, gasFreeOwnerAddress) && bytes.Equal(foo.ContractAddress, gasFreeContractAddress) {
|
||||
@@ -390,15 +391,13 @@ func (t *tron) tradeConfirmHandle(ctx context.Context) {
|
||||
var wg sync.WaitGroup
|
||||
|
||||
var handle = func(o model.Order) {
|
||||
conn, err := utils.NewTronGrpcClient(model.Endpoint(conf.Tron), model.GetK(model.RpcEndpointTronGridApiKey))
|
||||
conn, err := t.client()
|
||||
if err != nil {
|
||||
log.Task.Error("grpc.NewClient", err)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
defer conn.Close()
|
||||
|
||||
var c = api.NewWalletClient(conn)
|
||||
|
||||
idBytes, err := hex.DecodeString(o.RefHash)
|
||||
@@ -473,3 +472,45 @@ func (t *tron) rollBreak() bool {
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (t *tron) client() (*grpc.ClientConn, error) {
|
||||
var endpoint = model.Endpoint(conf.Tron)
|
||||
|
||||
t.connMu.RLock()
|
||||
if c, ok := t.conn[endpoint]; ok {
|
||||
state := c.GetState()
|
||||
if state == connectivity.Ready || state == connectivity.Idle {
|
||||
t.connMu.RUnlock()
|
||||
|
||||
return c, nil
|
||||
}
|
||||
|
||||
t.connMu.RUnlock()
|
||||
} else {
|
||||
t.connMu.RUnlock()
|
||||
}
|
||||
|
||||
t.connMu.Lock()
|
||||
defer t.connMu.Unlock()
|
||||
|
||||
if c, ok := t.conn[endpoint]; ok {
|
||||
state := c.GetState()
|
||||
if state == connectivity.Ready || state == connectivity.Idle {
|
||||
|
||||
return c, nil
|
||||
}
|
||||
|
||||
c.Close()
|
||||
}
|
||||
|
||||
conn, err := utils.NewTronGrpcClient(endpoint, model.GetK(model.RpcEndpointTronGridApiKey))
|
||||
if err != nil {
|
||||
|
||||
return nil, fmt.Errorf("连接失败: %w", err)
|
||||
}
|
||||
|
||||
t.conn[endpoint] = conn
|
||||
log.Task.Info("Tron gRPC 连接已建立:", endpoint)
|
||||
|
||||
return conn, nil
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"github.com/smallnest/chanx"
|
||||
"github.com/v03413/bepusdt/app/conf"
|
||||
"github.com/v03413/bepusdt/app/utils"
|
||||
)
|
||||
|
||||
func xlayerInit() {
|
||||
@@ -17,6 +18,7 @@ func xlayerInit() {
|
||||
RollDelayOffset: 3,
|
||||
ConfirmedOffset: 12,
|
||||
},
|
||||
Client: utils.NewHttpClient(),
|
||||
blockScanQueue: chanx.NewUnboundedChan[evmBlock](ctx, 30),
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"net"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
func NewHttpClient() *http.Client {
|
||||
return &http.Client{
|
||||
Timeout: time.Second * 30,
|
||||
Transport: &http.Transport{
|
||||
MaxIdleConns: 100,
|
||||
MaxIdleConnsPerHost: 10,
|
||||
MaxConnsPerHost: 20,
|
||||
IdleConnTimeout: 90 * time.Second,
|
||||
DisableKeepAlives: false,
|
||||
DisableCompression: false,
|
||||
ForceAttemptHTTP2: true,
|
||||
TLSHandshakeTimeout: 10 * time.Second,
|
||||
ResponseHeaderTimeout: 10 * time.Second,
|
||||
ExpectContinueTimeout: 1 * time.Second,
|
||||
DialContext: (&net.Dialer{
|
||||
Timeout: 10 * time.Second,
|
||||
KeepAlive: 30 * time.Second,
|
||||
}).DialContext,
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -9,9 +9,11 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/backoff"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/keepalive"
|
||||
"google.golang.org/grpc/metadata"
|
||||
)
|
||||
|
||||
// NewTronGrpcClient 目前很多 TRON API 基本都有QPS限制,过于激进或者过于保守的重试策略都不合适
|
||||
func NewTronGrpcClient(apiNode, apiKey string) (*grpc.ClientConn, error) {
|
||||
apiNode = strings.TrimSpace(apiNode)
|
||||
if apiNode == "" {
|
||||
@@ -24,10 +26,19 @@ func NewTronGrpcClient(apiNode, apiKey string) (*grpc.ClientConn, error) {
|
||||
|
||||
opts := []grpc.DialOption{
|
||||
grpc.WithConnectParams(grpc.ConnectParams{
|
||||
Backoff: backoff.Config{BaseDelay: 1 * time.Second, MaxDelay: 30 * time.Second, Multiplier: 1.5},
|
||||
Backoff: backoff.Config{
|
||||
BaseDelay: 1 * time.Second,
|
||||
MaxDelay: 30 * time.Second,
|
||||
Multiplier: 1.5,
|
||||
},
|
||||
MinConnectTimeout: 1 * time.Minute,
|
||||
}),
|
||||
grpc.WithTransportCredentials(insecure.NewCredentials()),
|
||||
grpc.WithKeepaliveParams(keepalive.ClientParameters{
|
||||
Time: 30 * time.Second,
|
||||
Timeout: 10 * time.Second,
|
||||
PermitWithoutStream: true,
|
||||
}),
|
||||
}
|
||||
|
||||
if apiKey != "" {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# 1Panel 部署 BEpusdt 教程
|
||||
# 1Panel 部署 BEpusdt 完整指南
|
||||
|
||||
> 📋 **前置条件**:本教程假定您已成功安装并配置好 1Panel 面板。
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
| 配置项 | 说明 |
|
||||
|----------|-----------------------------------------------------------------------------------------|
|
||||
| **镜像选择** | • **正式版**:`v03413/bepusdt:latest`(推荐生产环境)<br>• **开发版**:`v03413/bepusdt:nightly`(体验最新特性) |
|
||||
| **端口映射** | • **仅本机访问**:`127.0.0.1:8080:8080`(适合配合反向代理)<br>• **允许外网**:`8080:8080`(不推荐,建议使用反向代理) |
|
||||
| **端口映射** | • **本机访问**:`127.0.0.1:8080:8080`(推荐配合反向代理)<br>• **外网暴露**:`8080:8080`(不推荐,存在安全隐患) |
|
||||
|
||||
> ⚠️ **安全提示**:为保证安全,强烈建议使用 `127.0.0.1` 绑定本地,再通过反向代理对外提供服务。
|
||||
> ⚠️ **安全建议**:为确保服务安全,建议使用 `127.0.0.1` 绑定本地端口,再通过反向代理对外提供服务。
|
||||
|
||||
确认配置无误后,点击【**确认**】按钮启动容器。
|
||||
|
||||
@@ -31,14 +31,13 @@
|
||||
|
||||
### 第三步:验证启动状态
|
||||
|
||||
容器启动后,点击【**控制台**】查看日志输出。
|
||||
容器启动后,点击【**日志**】查看启动日志。
|
||||
|
||||
当看到以下日志信息时,表示服务已成功启动:
|
||||
当日志中出现服务监听地址和端口信息时,表示服务已成功启动:
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
✅ **启动成功标志**:日志中显示服务监听地址和端口信息
|
||||
✅ **启动成功标志**:日志显示服务正在监听指定地址和端口
|
||||
|
||||
---
|
||||
|
||||
@@ -46,78 +45,59 @@
|
||||
|
||||
### 为什么需要反向代理?
|
||||
|
||||
- ✅ 提供 HTTPS 安全访问
|
||||
- ✅ 启用 HTTPS 安全访问
|
||||
- ✅ 隐藏真实端口,提升安全性
|
||||
- ✅ 支持域名访问,更加专业
|
||||
- ✅ 支持自定义域名,展现专业形象
|
||||
|
||||
### 配置步骤
|
||||
|
||||
1. **进入网站管理**
|
||||
#### 1. 进入网站管理
|
||||
|
||||
返回 1Panel 首页 → 左侧菜单【**网站**】→ 点击【**创建网站**】→ 选择【**反向代理**】
|
||||
返回 1Panel 首页 → 左侧菜单【**网站**】→ 点击【**创建网站**】→ 选择【**反向代理**】
|
||||
|
||||
> 📌 **前提**:确保已安装 OpenResty
|
||||
> 📌 **前提条件**:确保已安装 OpenResty
|
||||
|
||||
2. **填写代理配置**
|
||||
#### 2. 填写代理配置
|
||||
|
||||

|
||||

|
||||
|
||||
#### 核心配置项
|
||||
| 配置项 | 填写示例 | 说明 |
|
||||
|----------|-------------------------|---------------|
|
||||
| **主域名** | `coin.example.com` | 填写您的域名 |
|
||||
| **代理地址** | `http://127.0.0.1:8080` | 指向容器运行端口 |
|
||||
| **其他设置** | 按需配置 | 如启用缓存、自定义请求头等 |
|
||||
|
||||
| 配置项 | 填写内容 | 说明 |
|
||||
|--------|-------------------------|------|
|
||||
| **主域名** | `coin.example.com` | 填写您的域名 |
|
||||
| **代理地址** | `http://127.0.0.1:8080` | 指向容器端口 |
|
||||
| **其他设置** | 按需配置 | 如启用缓存、设置请求头等 |
|
||||
#### 3. 完成域名解析
|
||||
|
||||
3. **完成域名解析**
|
||||
在域名服务商处添加 A 记录,将域名指向服务器 IP。
|
||||
|
||||
在域名服务商处添加 A 记录,将域名指向服务器 IP
|
||||
#### 4. 配置 HTTPS(强烈推荐)
|
||||
|
||||
4. **配置 HTTPS(强烈推荐)**
|
||||
|
||||
- 在网站管理中申请 SSL 证书
|
||||
- 启用 HTTPS 强制跳转
|
||||
- 提升安全性和用户信任度
|
||||
- 在网站管理中申请或上传 SSL 证书
|
||||
- 启用 HTTPS 强制跳转
|
||||
- 提升服务安全性和用户信任度
|
||||
|
||||
---
|
||||
|
||||
## 验证部署
|
||||
|
||||
配置完成后,通过浏览器访问您的域名,应该能正常访问 BEpusdt 服务。
|
||||
|
||||
### 访问测试
|
||||
|
||||
- **HTTP 访问**:`http://your-domain.com`
|
||||
- **HTTPS 访问**:`https://your-domain.com`(推荐)
|
||||
- **API 测试**:`https://your-domain.com/api/v1/health`
|
||||
配置完成后,通过浏览器访问您的域名,应能正常访问 BEpusdt 服务。
|
||||
|
||||
---
|
||||
|
||||
## 常见问题
|
||||
|
||||
**Q:无法访问服务怎么办?**
|
||||
**Q:无法访问服务,应如何排查?**
|
||||
|
||||
A:请依次检查:
|
||||
A:请依次检查以下项目:
|
||||
|
||||
1. 容器是否正常运行(查看日志)
|
||||
2. 端口是否被防火墙拦截
|
||||
3. 域名解析是否生效(`ping your-domain.com`)
|
||||
1. 容器是否正常运行(查看启动日志)
|
||||
2. 防火墙是否拦截相应端口
|
||||
3. 域名解析是否生效(执行 `ping your-domain.com` 验证)
|
||||
4. 反向代理配置是否正确
|
||||
|
||||
**Q:是否必须配置反向代理?**
|
||||
|
||||
A:不是必须,但强烈推荐。直接暴露端口存在安全风险,且无法使用 HTTPS。
|
||||
|
||||
**Q:如何更新到最新版本?**
|
||||
|
||||
A:
|
||||
|
||||
```bash
|
||||
# 拉取最新镜像
|
||||
docker pull v03413/bepusdt:latest
|
||||
|
||||
# 重新创建容器(通过 1Panel 操作)
|
||||
```
|
||||
A:不是必须配置,但我们强烈推荐。直接暴露容器端口存在安全风险,且无法使用 HTTPS 加密传输。
|
||||
|
||||
---
|
||||
|
||||
|
After Width: | Height: | Size: 196 KiB |
|
After Width: | Height: | Size: 141 KiB |
|
After Width: | Height: | Size: 48 KiB |
|
Before Width: | Height: | Size: 214 KiB After Width: | Height: | Size: 214 KiB |
@@ -1,40 +1,52 @@
|
||||
# 宝塔部署 BEpusdt 教程
|
||||
# 宝塔面板部署 BEpusdt 完整指南
|
||||
|
||||
> 前言:曾经我也是忠实的宝塔用户,至少7.7版本之前是;现在明确不推荐BEpusdt用户使用此面板,
|
||||
> 哪怕你是用[1Panel](https://github.com/1Panel-dev/1Panel) 也行。作为一款以“开源”起家的面板,现如今连社区版用户竟然也需要强绑账号,其存在的加密模块以及屡次的安全问题这里不再重提。
|
||||
本教程假设你已成功安装宝塔面板。请按照以下步骤进行部署。
|
||||
|
||||
教程开始,默认你已经成功安装宝塔面板。
|
||||
## 部署步骤
|
||||
|
||||
## 配置文件准备
|
||||
### 步骤一:创建容器
|
||||
|
||||
文件:https://github.com/v03413/BEpusdt/releases/latest/download/linux-amd64-BEpusdt.tar.gz 下载解压,将文件夹重命名为
|
||||
`BEpusdt`,然后将其上传到服务器的 `/opt` 目录下。
|
||||
首先确保已安装 Docker 模块。如未安装,请在宝塔面板中完成安装。
|
||||
|
||||

|
||||
打开配置文件`conf.simple.toml`进行调整,红框所示内容必须修改,同时最好增加指定日志和数据文件路径。
|
||||

|
||||
|
||||
```toml
|
||||
output_log = "/opt/BEpusdt/bepusdt.log"
|
||||
sqlite_path = "/opt/BEpusdt/sqlite.db"
|
||||
```
|
||||
### 步骤二:配置容器参数
|
||||
|
||||

|
||||
确保二进制文件`bepusdt`拥有如图权限。
|
||||

|
||||
|
||||
## 配置进程守护
|
||||
根据以下说明配置容器参数:
|
||||
|
||||
宝塔应用商店中搜索`进程守护管理器`,安装后进入应用,随后添加守护进程。
|
||||

|
||||
| 配置项 | 说明 |
|
||||
|----------|------------------------------------------------------------|
|
||||
| **镜像** | 正式版:`v03413/bepusdt:latest` / 开发版:`v03413/bepusdt:nightly` |
|
||||
| **端口** | 反向代理场景:按图配置;外网暴露:两个端口均填 `8080` 并勾选"对外暴露" |
|
||||
| **重启规则** | 无特殊需求时按图中默认配置 |
|
||||
|
||||
运行目录:`/opt/BEpusdt`
|
||||
启动命令:`/opt/BEpusdt/bepusdt -conf /opt/BEpusdt/conf.simple.toml`
|
||||
配置完成后,点击右下角**创建**按钮,等待容器创建完成。
|
||||
|
||||

|
||||
确认添加,随后查看日志如图,即代表部署启动成功,bot也会收到启动消息。
|
||||
### 步骤三:验证容器启动
|
||||
|
||||
返回容器列表,找到新建的 BEpusdt 容器,依次点击**操作** → **更多** → **日志**查看启动日志。
|
||||
|
||||

|
||||
|
||||
**成功标志**:日志中出现如上所示内容表示启动成功。
|
||||
|
||||
若已对外暴露 8080 端口,访问 `http://<服务器IP>:8080` 可查看初始化页面。
|
||||
|
||||
## 配置反向代理
|
||||
|
||||
宝塔面板 -> 添加站点(PHP版本: 纯静态),随后配置添加一个反向代理,如图:
|
||||

|
||||
### 创建站点和反向代理
|
||||
|
||||
添加之间后确保域名解析成功,访问你的域名,如果能正确打开即代表反向代理成功,推荐启用HTTPS,方法这里不再阐述。
|
||||
在宝塔面板中执行以下操作:
|
||||
|
||||
1. 添加站点(PHP 版本选择**纯静态**)
|
||||
2. 为该站点配置反向代理,如下图所示:
|
||||
|
||||

|
||||
|
||||
### 验证配置
|
||||
|
||||
- 确保域名已正确解析
|
||||
- 访问你的域名,能正常打开即表示反向代理配置成功
|
||||
- **建议启用 HTTPS** 以提高安全性
|
||||
|
Before Width: | Height: | Size: 189 KiB |
|
Before Width: | Height: | Size: 107 KiB |
|
Before Width: | Height: | Size: 185 KiB |
|
Before Width: | Height: | Size: 119 KiB |
@@ -1,30 +1,72 @@
|
||||
# Linux 手动安装
|
||||
|
||||
**默认认为您已经掌握 Linux 的操作常识,否则后续没有查看必要。**
|
||||
> ⚠️ **前置说明**:本教程假定您已掌握 Linux 基本操作,包括命令行使用、文件管理等常识。
|
||||
|
||||
准备服务器,Debian12+,架构目前只对amd64做了测试,其他架构请自行测试;依次执行以下命令:
|
||||
## 系统要求
|
||||
|
||||
| 项目 | 要求 |
|
||||
|-----------|------------------|
|
||||
| **操作系统** | Debian 12 或更高版本 |
|
||||
| **处理器架构** | amd64(其他架构请自行测试) |
|
||||
|
||||
## 安装步骤
|
||||
|
||||
执行以下命令依次完成安装:
|
||||
|
||||
### 1. 下载安装包
|
||||
|
||||
```bash
|
||||
|
||||
# 下载对应架构版本
|
||||
wget -O ./bepusdt.zip https://github.com/v03413/bepusdt/releases/latest/download/bepusdt-linux-amd64.zip
|
||||
```
|
||||
|
||||
# 解压
|
||||
### 2. 解压文件
|
||||
|
||||
```bash
|
||||
unzip ./bepusdt.zip
|
||||
```
|
||||
|
||||
# 解压结构如下:
|
||||
#root@debian:~# tree ./bepusdt
|
||||
#./bepusdt
|
||||
#├── bepusdt
|
||||
#├── bepusdt.service
|
||||
解压后的目录结构如下:
|
||||
|
||||
# 配置软件自启
|
||||
```
|
||||
./bepusdt
|
||||
├── bepusdt # 可执行文件
|
||||
└── bepusdt.service # systemd 服务配置文件
|
||||
```
|
||||
|
||||
### 3. 配置系统自启
|
||||
|
||||
```bash
|
||||
# 将 service 文件移动到 systemd 目录
|
||||
mv ./bepusdt/bepusdt.service /etc/systemd/system
|
||||
|
||||
# 启用服务自启
|
||||
systemctl enable bepusdt.service
|
||||
```
|
||||
|
||||
# 启动软件
|
||||
### 4. 启动服务
|
||||
|
||||
```bash
|
||||
# 启动 BEpusdt 服务
|
||||
systemctl start bepusdt.service
|
||||
```
|
||||
|
||||
# 查看软件状态(看到 Active: active (running) 即成功启动)
|
||||
### 5. 验证启动状态
|
||||
|
||||
```bash
|
||||
# 查看服务状态
|
||||
systemctl status bepusdt.service
|
||||
```
|
||||
```
|
||||
|
||||
✅ **成功标志**:看到 `Active: active (running)` 表示服务已成功启动
|
||||
|
||||
---
|
||||
|
||||
## 常用命令
|
||||
|
||||
| 操作 | 命令 |
|
||||
|----------|-------------------------------------|
|
||||
| **查看状态** | `systemctl status bepusdt.service` |
|
||||
| **查看日志** | `journalctl -u bepusdt.service -f` |
|
||||
| **重启服务** | `systemctl restart bepusdt.service` |
|
||||
| **停止服务** | `systemctl stop bepusdt.service` |
|
||||
@@ -394,14 +394,25 @@ const getCurrencySymbol = (fiat: string) => currencySymbolMap[fiat] || "";
|
||||
font-family: "Monaco", "Menlo", "Consolas", monospace;
|
||||
font-size: 12px;
|
||||
color: var(--color-text-3);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.tx-url-link {
|
||||
display: block;
|
||||
display: inline-block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
max-width: 100%;
|
||||
vertical-align: bottom;
|
||||
}
|
||||
|
||||
.hash-value :deep(.arco-link) {
|
||||
display: inline-block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
max-width: 100%;
|
||||
vertical-align: bottom;
|
||||
}
|
||||
|
||||
.currency-symbol {
|
||||
|
||||
@@ -97,9 +97,9 @@
|
||||
<a-input-number
|
||||
v-model="syntaxValue"
|
||||
:placeholder="getSyntaxPlaceholder()"
|
||||
:precision="syntaxType === '~' ? 2 : 6"
|
||||
:min="syntaxType === '~' ? 0.01 : 0"
|
||||
:min="syntaxType === '~' ? 0.000001 : 0"
|
||||
:max="syntaxType === '~' ? 10 : 999999"
|
||||
:step="syntaxType === '~' ? 0.000001 : 0.01"
|
||||
style="width: 100%"
|
||||
>
|
||||
<template #prefix v-if="syntaxType">
|
||||
@@ -259,7 +259,7 @@ const columns = [
|
||||
title: "交易法币",
|
||||
dataIndex: "fiat",
|
||||
align: "center",
|
||||
width: 240,
|
||||
width: 160,
|
||||
slotName: "fiat",
|
||||
filterable: {
|
||||
filters: [
|
||||
@@ -277,7 +277,7 @@ const columns = [
|
||||
title: "加密货币",
|
||||
dataIndex: "crypto",
|
||||
align: "center",
|
||||
width: 240,
|
||||
width: 140,
|
||||
slotName: "crypto",
|
||||
filterable: {
|
||||
filters: [
|
||||
@@ -294,14 +294,15 @@ const columns = [
|
||||
{
|
||||
title: "汇率浮动",
|
||||
dataIndex: "syntax",
|
||||
slotName: "syntax"
|
||||
slotName: "syntax",
|
||||
width: 480
|
||||
},
|
||||
{
|
||||
title: "操作",
|
||||
slotName: "optional",
|
||||
align: "center",
|
||||
fixed: "right",
|
||||
width: "200"
|
||||
width: 120
|
||||
}
|
||||
];
|
||||
|
||||
@@ -316,14 +317,26 @@ const parseSyntax = (syntax: string) => {
|
||||
|
||||
const generateSyntax = () => {
|
||||
if (syntaxValue.value === undefined || syntaxValue.value === null) return "";
|
||||
return syntaxType.value + syntaxValue.value.toString();
|
||||
|
||||
// 格式化数值,去除末尾的0
|
||||
const formatValue = (val: number) => {
|
||||
return parseFloat(val.toFixed(6)).toString();
|
||||
};
|
||||
|
||||
// 百分比浮动
|
||||
if (syntaxType.value === "~") {
|
||||
return syntaxType.value + formatValue(syntaxValue.value);
|
||||
}
|
||||
|
||||
// 其他类型
|
||||
return syntaxType.value + formatValue(syntaxValue.value);
|
||||
};
|
||||
|
||||
const getSyntaxPlaceholder = () => {
|
||||
const placeholders = {
|
||||
"+": "如:0.3",
|
||||
"-": "如:0.2",
|
||||
"~": "如:1.02 或 0.97",
|
||||
"~": "如:1.020000 或 0.970000",
|
||||
"": "如:7.4"
|
||||
};
|
||||
return placeholders[syntaxType.value as keyof typeof placeholders];
|
||||
@@ -335,30 +348,40 @@ const getTableSyntaxDescription = (syntax: string) => {
|
||||
const parsed = parseSyntax(syntax);
|
||||
if (parsed.value === undefined || parsed.value === null) return "";
|
||||
|
||||
// 格式化数值,去除末尾的0
|
||||
const formatValue = (val: number) => {
|
||||
return parseFloat(val.toFixed(6)).toString();
|
||||
};
|
||||
|
||||
switch (parsed.type) {
|
||||
case "+":
|
||||
return `订单汇率 = 基准汇率 + ${parsed.value}`;
|
||||
return `订单汇率 = 基准汇率 + ${formatValue(parsed.value)}`;
|
||||
case "-":
|
||||
return `订单汇率 = 基准汇率 - ${parsed.value}`;
|
||||
return `订单汇率 = 基准汇率 - ${formatValue(parsed.value)}`;
|
||||
case "~":
|
||||
return parsed.value != 1 ? `订单汇率 = 基准汇率 * ${parsed.value}` : `订单汇率 = 基准汇率`;
|
||||
return parsed.value != 1 ? `订单汇率 = 基准汇率 * ${formatValue(parsed.value)}` : `订单汇率 = 基准汇率`;
|
||||
default:
|
||||
return `订单汇率强制固定 ${parsed.value}`;
|
||||
return `订单汇率强制固定 ${formatValue(parsed.value)}`;
|
||||
}
|
||||
};
|
||||
|
||||
const getFormSyntaxDescription = () => {
|
||||
if (!syntaxType.value || syntaxValue.value === undefined || syntaxValue.value === null) return "";
|
||||
|
||||
// 格式化数值,去除末尾的0
|
||||
const formatValue = (val: number) => {
|
||||
return parseFloat(val.toFixed(6)).toString();
|
||||
};
|
||||
|
||||
switch (syntaxType.value) {
|
||||
case "+":
|
||||
return `订单汇率 = 基准汇率 + ${syntaxValue.value}`;
|
||||
return `订单汇率 = 基准汇率 + ${formatValue(syntaxValue.value)}`;
|
||||
case "-":
|
||||
return `订单汇率 = 基准汇率 - ${syntaxValue.value}`;
|
||||
return `订单汇率 = 基准汇率 - ${formatValue(syntaxValue.value)}`;
|
||||
case "~":
|
||||
return syntaxValue.value != 1 ? `订单汇率 = 基准汇率 * ${syntaxValue.value}` : `订单汇率 = 基准汇率`;
|
||||
return syntaxValue.value != 1 ? `订单汇率 = 基准汇率 * ${formatValue(syntaxValue.value)}` : `订单汇率 = 基准汇率`;
|
||||
default:
|
||||
return `订单汇率强制固定 ${syntaxValue.value}`;
|
||||
return `订单汇率强制固定 ${formatValue(syntaxValue.value)}`;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -589,12 +612,13 @@ getCommonTableList();
|
||||
.syntax-display {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
gap: 12px;
|
||||
white-space: nowrap;
|
||||
|
||||
.syntax-value {
|
||||
font-weight: 500;
|
||||
color: #262626;
|
||||
width: 50px;
|
||||
min-width: 80px;
|
||||
text-align: left;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
@@ -603,7 +627,7 @@ getCommonTableList();
|
||||
font-size: 12px;
|
||||
color: #8c8c8c;
|
||||
font-style: italic;
|
||||
flex: 1;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||