mirror of
https://github.com/bestnite/sub2clash.git
synced 2025-07-04 20:02:34 +08:00
🔧 customize HTTP user-agent for fetching subscription from API.
This commit is contained in:
@ -32,7 +32,7 @@ func BuildSub(clashType model.ClashType, query validator.SubValidator, template
|
||||
template = query.Template
|
||||
}
|
||||
if strings.HasPrefix(template, "http") {
|
||||
templateBytes, err = common.LoadSubscription(template, query.Refresh)
|
||||
templateBytes, err = common.LoadSubscription(template, query.Refresh, query.UserAgent)
|
||||
if err != nil {
|
||||
logger.Logger.Debug(
|
||||
"load template failed", zap.String("template", template), zap.Error(err),
|
||||
@ -61,7 +61,7 @@ func BuildSub(clashType model.ClashType, query validator.SubValidator, template
|
||||
var proxyList []model.Proxy
|
||||
// 加载订阅
|
||||
for i := range query.Subs {
|
||||
data, err := common.LoadSubscription(query.Subs[i], query.Refresh)
|
||||
data, err := common.LoadSubscription(query.Subs[i], query.Refresh, query.UserAgent)
|
||||
subName := ""
|
||||
if strings.Contains(query.Subs[i], "#") {
|
||||
subName = query.Subs[i][strings.LastIndex(query.Subs[i], "#")+1:]
|
||||
|
@ -75,6 +75,12 @@
|
||||
<label for="proxy">节点分享链接:</label>
|
||||
<textarea class="form-control" id="proxy" name="proxy" placeholder="每行输入一个节点分享链接" rows="5"></textarea>
|
||||
</div>
|
||||
<!-- User Agent -->
|
||||
<div class="form-group mb-3">
|
||||
<label for="user-agent">ua标识:</label>
|
||||
<textarea class="form-control" id="user-agent" name="user-agent"
|
||||
placeholder="用于获取订阅的http请求中的user-agent标识(可选)" rows="1"></textarea>
|
||||
</div>
|
||||
<!-- Refresh -->
|
||||
<div class="form-check mb-3">
|
||||
<input class="form-check-input" id="refresh" name="refresh" type="checkbox" />
|
||||
@ -172,4 +178,5 @@
|
||||
</div>
|
||||
</body>
|
||||
<script src="./static/index.js"></script>
|
||||
|
||||
</html>
|
@ -66,6 +66,11 @@ function generateURI() {
|
||||
// alert("订阅链接和节点分享链接不能同时为空!");
|
||||
return "";
|
||||
}
|
||||
|
||||
// 获取订阅user-agent标识
|
||||
const userAgent = document.getElementById("user-agent").value;
|
||||
queryParams.push(`userAgent=${userAgent}`)
|
||||
|
||||
// 获取复选框的值
|
||||
const refresh = document.getElementById("refresh").checked;
|
||||
queryParams.push(`refresh=${refresh ? "true" : "false"}`);
|
||||
|
Reference in New Issue
Block a user