Skip to content

Commit

Permalink
blocked youtube temporarily to add life time of siteproxy.herkoapp.com
Browse files Browse the repository at this point in the history
  • Loading branch information
netptop committed Apr 10, 2020
1 parent f551b49 commit faea7d3
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 13 deletions.
9 changes: 8 additions & 1 deletion Proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ let getHostFromReq = (req) => { //return target
}


let Proxy = ({urlModify, httpprefix, serverName, port, cookieDomainRewrite, locationReplaceMap302, regReplaceMap, siteSpecificReplace, pathReplace}) => {
let Proxy = ({blockedSites, urlModify, httpprefix, serverName, port, cookieDomainRewrite, locationReplaceMap302, regReplaceMap, siteSpecificReplace, pathReplace}) => {
let handleRespond = ({req, res, body, gbFlag}) => {
// logSave("res from proxied server:", body);
let myRe
Expand Down Expand Up @@ -330,6 +330,13 @@ let Proxy = ({urlModify, httpprefix, serverName, port, cookieDomainRewrite, loca
let fwdStr = req.headers['X-Forwarded-For'] || req.headers['x-forwarded-for']

let {host, httpType} = getHostFromReq(req)
for (let i=0; i<blockedSites.length; i++) {
let site = blockedSites[i]
if (site === host) {
res.status(404).send(`{"blockedSite":true}`)
return
}
}
console.log(`httpType:${httpType}, host:${host}`)
if (host.indexOf(serverName) !== -1 || // we cannot request resource from proxy itself
host == '' || host.indexOf('.') === -1 || (fwdStr && fwdStr.split(',').length > 3)) { // too many forwardings
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ user browser +-------------->+ siteproxy +-------> wikipedia
5. now
6. find your domain name from now cli, then replace serverName in 'config.js', like:
serverName: 'siteproxy.herokuapp.com' ====> 'your-domain-name.now.sh'
7. now --prod
8. done
7. change "blockedSites = ['www.youtube.com', 'm.youtube.com']" ====> "blockedSites = []" if you want to support youtube
8. now --prod
9. done
```
## Telegram群: @siteproxy
## email: [email protected]
Expand Down
4 changes: 2 additions & 2 deletions api/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ const fs = require('fs')
const path = require('path')
var Proxy = require('../Proxy')

let { urlModify, httpprefix, serverName, port, locationReplaceMap302, regReplaceMap, siteSpecificReplace, pathReplace } = require('../config')
let { blockedSites, urlModify, httpprefix, serverName, port, locationReplaceMap302, regReplaceMap, siteSpecificReplace, pathReplace } = require('../config')

let cookieDomainRewrite = serverName

let proxy = Proxy({ urlModify, httpprefix, serverName, port, cookieDomainRewrite, locationReplaceMap302, regReplaceMap, siteSpecificReplace, pathReplace })
let proxy = Proxy({ blockedSites, urlModify, httpprefix, serverName, port, cookieDomainRewrite, locationReplaceMap302, regReplaceMap, siteSpecificReplace, pathReplace })
export default (req, res) => {
const dirPath = path.join(__dirname + '/..', req.url)
console.log(`x-forward-for:${req.headers['x-forwarded-for']}, req.url:${req.url}`)
Expand Down
4 changes: 3 additions & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ let config = {
httpprefix: 'https', port: 443,
serverName: 'siteproxy.herokuapp.com',
}
let blockedSites = ['www.youtube.com', 'm.youtube.com', 'merlinblog.xyz']

if (process.env.herokuAddr) {
config.serverName = process.env.herokuAddr
}
Expand Down Expand Up @@ -209,4 +211,4 @@ const siteSpecificReplace = {
}
}

module.exports = { urlModify, httpprefix, serverName, port, locationReplaceMap302, regReplaceMap, siteSpecificReplace, pathReplace }
module.exports = { blockedSites, urlModify, httpprefix, serverName, port, locationReplaceMap302, regReplaceMap, siteSpecificReplace, pathReplace }
6 changes: 2 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@
<br />
<div class="descriptionSeg">4.由于从本代理发出的Google请求过多, google会自动限制搜索流量; 如果google不能用,请使用bing和yahoo搜索引擎. </div>
<br />
<div class="descriptionSeg">5.使用手机打开youtube时, 页面顶端有一个搜索条, 可以中文搜索. </div>
<div class="descriptionSeg">5. Youtube的代理暂时关闭了, 以尽量延长本代理生命时间</div>
<br />
<div class="descriptionSeg">6.请降低youtube视频的分辨率,因为免费服务器每月的流量非常非常有限, 超过的话其他人都无法使用了 </div>
<br />
<div class="descriptionSeg">7.请登录telegram,加群@siteproxy,以便及时获取更新</div>
<div class="descriptionSeg">6.请登录telegram,加群@siteproxy,以便及时获取更新</div>
<form class="lead-title">
<p>指定网址:<input class="lead-title" type="text" id="address" value="https://www.google.com">
<input id="addrAccess" class="lead-title button1" type="button" onclick="onsubmit" value="访问网站"/>
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ const path = require('path')
const fs = require('fs')
let app = express()
var Proxy = require('./Proxy')
let { urlModify, httpprefix, serverName, port, locationReplaceMap302, regReplaceMap, siteSpecificReplace, pathReplace } = require('./config')
let { blockedSites, urlModify, httpprefix, serverName, port, locationReplaceMap302, regReplaceMap, siteSpecificReplace, pathReplace } = require('./config')

let cookieDomainRewrite = serverName
let proxy = Proxy({ urlModify, httpprefix, serverName, port, cookieDomainRewrite, locationReplaceMap302, regReplaceMap, siteSpecificReplace, pathReplace})
let proxy = Proxy({ blockedSites, urlModify, httpprefix, serverName, port, cookieDomainRewrite, locationReplaceMap302, regReplaceMap, siteSpecificReplace, pathReplace})

const middle1 = (req, res, next) => {
console.log(`req.url:${req.url}`)
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"test": "jest",
"localtest": "localFlag=true jest",
"start": "node --tls-min-v1.0 index.js",
"localstart": "localFlag=true node --tls-min-v1.0 index.js"
"localstartNow": "localFlag=true node --tls-min-v1.0 index.js",
"localstart": "PORT=8011 localFlag=true heroku local web"
},
"keywords": [],
"author": "netptop",
Expand Down

0 comments on commit faea7d3

Please sign in to comment.