Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
U
UnblockNeteaseMusic
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirror From Github
UnblockNeteaseMusic
Commits
d2a8d120
Commit
d2a8d120
authored
5 years ago
by
Silvan
Browse files
Options
Downloads
Patches
Plain Diff
fix infinite loop&modify shell
parent
d922fd1a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
README.md
+1
-1
1 addition, 1 deletion
README.md
build.sh
+1
-1
1 addition, 1 deletion
build.sh
createCertificate.sh
+7
-3
7 additions, 3 deletions
createCertificate.sh
proxy/proxy.go
+35
-1
35 additions, 1 deletion
proxy/proxy.go
with
44 additions
and
6 deletions
README.md
+
1
−
1
View file @
d2a8d120
...
...
@@ -42,7 +42,7 @@ sudo ./UnblockNeteaseMusic
本应用获取music.163.com的IP是通过本机直接查询,非nodejs版本请求music.httpdns.c.163.com获取
已知:
1.
windows版本的网易云音乐需要在应用内设置代理
127.0.0.1
端口 80
1.
windows版本的网易云音乐需要在应用内
设置代理
Http地址为「HttpProxy」下任意地址
端口 80
2.
Linux 客户端 (1.2 版本以上需要在终端启动增加 --ignore-certificate-errors 参数)
3.
咪咕源貌似部分宽带无法使用
# 感谢
...
...
This diff is collapsed.
Click to expand it.
build.sh
+
1
−
1
View file @
d2a8d120
CurrentVersion
=
0.1.
5
CurrentVersion
=
0.1.
6
Project
=
github.com/cnsilvan/UnblockNeteaseMusic
Path
=
"
$Project
/version"
ExecName
=
"UnblockNeteaseMusic"
...
...
This diff is collapsed.
Click to expand it.
createCertificate.sh
+
7
−
3
View file @
d2a8d120
...
...
@@ -9,12 +9,16 @@ caKey="$basepath/ca.key"
# 生成 CA 私钥
openssl genrsa
-out
"
${
caKey
}
"
2048
# 生成 CA 证书
openssl req
-x509
-new
-nodes
-key
"
${
caKey
}
"
-sha256
-days
1
825
-out
"
${
caCrt
}
"
-subj
"/C=CN/CN=UnblockNeteaseMusic Root CA/O=UnblockNeteaseMusic"
openssl req
-x509
-new
-nodes
-key
"
${
caKey
}
"
-sha256
-days
825
-out
"
${
caCrt
}
"
-subj
"/C=CN/CN=UnblockNeteaseMusic Root CA/O=UnblockNeteaseMusic"
# 生成服务器私钥
openssl genrsa
-out
"
${
serverKey
}
"
2048
# 生成证书签发请求
openssl req
-new
-sha256
-key
"
${
serverKey
}
"
-out
"
${
serverCsr
}
"
-subj
"/C=CN/L=Hangzhou/O=NetEase (Hangzhou) Network Co., Ltd/OU=IT Dept./CN=*.music.163.com"
# 使用 CA 签发服务器证书
touch
"
${
extFile
}
"
echo
"subjectAltName=DNS:music.163.com,DNS:*.music.163.com"
>
"
${
extFile
}
"
openssl x509
-req
-extfile
"
${
extFile
}
"
-days
1825
-in
"
${
serverCsr
}
"
-CA
"
${
caCrt
}
"
-CAkey
"
${
caKey
}
"
-CAcreateserial
-out
"
${
serverCrt
}
"
echo
"authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage=digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
extendedKeyUsage=serverAuth,OCSPSigning
subjectAltName=DNS:music.163.com,DNS:*.music.163.com"
>
"
${
extFile
}
"
openssl x509
-req
-extfile
"
${
extFile
}
"
-days
825
-in
"
${
serverCsr
}
"
-CA
"
${
caCrt
}
"
-CAkey
"
${
caKey
}
"
-CAcreateserial
-out
"
${
serverCrt
}
"
This diff is collapsed.
Click to expand it.
proxy/proxy.go
+
35
−
1
View file @
d2a8d120
...
...
@@ -19,9 +19,31 @@ import (
type
HttpHandler
struct
{}
var
localhost
=
map
[
string
]
int
{}
func
InitProxy
()
{
fmt
.
Println
(
"-------------------Init Proxy-------------------"
)
address
:=
"0.0.0.0:"
addrs
,
err
:=
net
.
InterfaceAddrs
()
if
err
!=
nil
{
panic
(
err
)
}
for
_
,
address
:=
range
addrs
{
if
ipnet
,
ok
:=
address
.
(
*
net
.
IPNet
);
ok
&&
!
ipnet
.
IP
.
IsLoopback
()
{
if
ipnet
.
IP
.
To4
()
!=
nil
{
localhost
[
ipnet
.
IP
.
String
()]
=
1
}
if
ipnet
.
IP
.
To16
()
!=
nil
{
localhost
[
ipnet
.
IP
.
To16
()
.
String
()]
=
1
}
}
}
var
localhostKey
[]
string
for
k
,
_
:=
range
localhost
{
localhostKey
=
append
(
localhostKey
,
k
)
}
fmt
.
Println
(
"Http Proxy:"
)
fmt
.
Println
(
strings
.
Join
(
localhostKey
,
" , "
))
go
startTlsServer
(
address
+
strconv
.
Itoa
(
*
config
.
TLSPort
),
*
config
.
CertFile
,
*
config
.
KeyFile
,
&
HttpHandler
{})
go
startServer
(
address
+
strconv
.
Itoa
(
*
config
.
Port
),
&
HttpHandler
{})
}
...
...
@@ -47,7 +69,14 @@ func (h *HttpHandler) ServeHTTP(resp http.ResponseWriter, request *http.Request)
if
len
(
request
.
URL
.
Scheme
)
>
0
{
scheme
=
request
.
URL
.
Scheme
+
"://"
}
if
strings
.
Contains
(
hostStr
,
"localhost"
)
||
strings
.
Contains
(
hostStr
,
"127.0.0.1"
)
||
strings
.
Contains
(
hostStr
,
"0.0.0.0"
)
||
(
len
(
path
)
>
1
&&
strings
.
Count
(
path
,
"/"
)
>
1
&&
bytes
.
EqualFold
(
left
,
right
))
{
infinite
:=
false
for
k
,
_
:=
range
localhost
{
if
strings
.
Contains
(
hostStr
,
k
)
{
infinite
=
true
break
}
}
if
infinite
||
strings
.
Contains
(
hostStr
,
"localhost"
)
||
strings
.
Contains
(
hostStr
,
"127.0.0.1"
)
||
strings
.
Contains
(
hostStr
,
"0.0.0.0"
)
||
(
len
(
path
)
>
1
&&
strings
.
Count
(
path
,
"/"
)
>
1
&&
bytes
.
EqualFold
(
left
,
right
))
{
//cause infinite loop
requestURI
=
scheme
+
request
.
Host
if
bytes
.
EqualFold
(
left
,
right
)
{
...
...
@@ -162,6 +191,11 @@ func (h *HttpHandler) ServeHTTP(resp http.ResponseWriter, request *http.Request)
}
}
func
proxyConnectLocalhost
(
rw
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
fmt
.
Printf
(
"Local Received request %s %s %s
\n
"
,
req
.
Method
,
req
.
Host
,
req
.
RemoteAddr
,
)
hij
,
ok
:=
rw
.
(
http
.
Hijacker
)
if
!
ok
{
fmt
.
Println
(
"HTTP Server does not support hijacking"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment