phil 发表于 2023-7-12 17:17:47

CF反代U2B还能实现吗

CF反代U2B还能实现吗

王者荣耀射手小伟 发表于 2023-7-12 17:43:02

应该不行了,之前的好像老是弹验证码

魔法巴拉 发表于 2023-7-12 18:39:02

这个代码年久失修了,你试试看,可能要改一些地方

// List of domains bind to your WorkersProxy.
const domain_list = ['https://cdn.reverse-proxy.live/', 'https://ytb.yanyu.workers.dev/']

// Website you intended to retrieve for users.
const upstream = 'https://www.youtube.com/'

// Website you intended to retrieve for users using mobile devices.
const upstream_mobile = 'https://www.youtube.com/'

// Countries and regions where you wish to suspend your service.
const blocked_region = []

// IP addresses which you wish to block from using your service.
const blocked_ip_address = []

addEventListener('fetch', event => {
    event.respondWith(fetchAndApply(event.request));
})

async function fetchAndApply(request) {

    const region = request.headers.get('cf-ipcountry').toUpperCase();
    const ip_address = request.headers.get('cf-connecting-ip');
    const user_agent = request.headers.get('user-agent');
    let response = null;
    let url = request.url;

    if (await device_status(user_agent)){
      upstream_domain = upstream
    } else {
      upstream_domain = upstream_mobile
    }

    for(let domain of domain_list) {
      url = url.replace(domain, upstream_domain)
    };

    if (blocked_region.includes(region)) {
      response = new Response('Access denied: WorkersProxy is not available in your region yet.', {
            status: 403
      });
    } else if(blocked_ip_address.includes(ip_address)){
      response = new Response('Access denied: Your IP address is blocked by WorkersProxy.', {
            status: 403
      });
    } else{
      let method = request.method;
      let headers = request.headers;
      response = fetch(url, {
            method: method,
            headers: headers
      })
    }
    return response;
}

async function device_status (userAgentInfo) {
    var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"];
    var flag = true;
    for (var v = 0; v < Agents.length; v++) {
      if (userAgentInfo.indexOf(Agents) > 0) {
            flag = false;
            break;
      }
    }
    return flag;
}

dave 发表于 2023-7-14 15:04:30

魔法巴拉 发表于 2023-7-12 18:39
这个代码年久失修了,你试试看,可能要改一些地方

CF WORKER还有什么玩法????
贴几期教学贴吧

魔法巴拉 发表于 2023-7-14 15:25:06

dave 发表于 2023-7-14 15:04
CF WORKER还有什么玩法????
贴几期教学贴吧

基本上反代的都可以做,人有多大胆,cf有多大产,我接了单子,最近没时间搞了

zip 发表于 2023-7-15 00:31:18

什么单?又是论坛?

lewiet 发表于 2023-7-15 00:42:19

魔法巴拉 发表于 2023-7-14 15:25
基本上反代的都可以做,人有多大胆,cf有多大产,我接了单子,最近没时间搞了 ...

不经常制造热点论坛很快会荒废的
页: [1]
查看完整版本: CF反代U2B还能实现吗