Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
8e42a657
Unverified
Commit
8e42a657
authored
Jul 19, 2018
by
老广
Committed by
GitHub
Jul 19, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1560 from wojiushixiaobai/dev
[Update]替换淘宝IP查询接口
parents
c94d018d
e1fff18c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
utils.py
apps/users/utils.py
+4
-4
No files found.
apps/users/utils.py
View file @
8e42a657
...
...
@@ -212,10 +212,10 @@ def write_login_log(*args, **kwargs):
def
get_ip_city
(
ip
,
timeout
=
10
):
# Taobao ip api: http://ip.taobao.com/
/
service/getIpInfo.php?ip=8.8.8.8
# Taobao ip api: http://ip.taobao.com/service/getIpInfo.php?ip=8.8.8.8
# Sina ip api: http://int.dpool.sina.com.cn/iplookup/iplookup.php?ip=8.8.8.8&format=json
url
=
'http://i
nt.dpool.sina.com.cn/iplookup/iplookup.php?ip=
%
s&format=json
'
%
ip
url
=
'http://i
p.taobao.com/service/getIpInfo.php?ip=
%
s
'
%
ip
try
:
r
=
requests
.
get
(
url
,
timeout
=
timeout
)
except
:
...
...
@@ -224,8 +224,8 @@ def get_ip_city(ip, timeout=10):
if
r
and
r
.
status_code
==
200
:
try
:
data
=
r
.
json
()
if
not
isinstance
(
data
,
int
)
and
data
[
'
ret'
]
==
1
:
city
=
data
[
'
country'
]
+
' '
+
data
[
'city'
]
if
not
isinstance
(
data
,
int
)
and
data
[
'
code'
]
==
0
:
city
=
data
[
'
data'
][
'country'
]
+
' '
+
data
[
'data'
]
[
'city'
]
except
ValueError
:
pass
return
city
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment