-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
23 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"repository_name":"myip","body":"# myip\n\n返回本机的公网 IP 以及访问外网的公网 IP,使用 http:/www.ip111.cn 以及 http://www.ip138.com 提供的服务。\n查看[文档](https://crystal-china.github.io/myip/)获取更多帮助\n\n```sh\n ╰─ $ bin/myip \nip111.cn:从国内测试:123.123.123.123 中国 北京市\nip138.com:您的iP地址是:[123.123.123.123 ] 来自:中国北京市西城区 联通\nip111.cn:从国外测试:111.111.111.111 美国 洛杉矶\nip111.cn:从谷歌测试:111.111.111.111 美国 洛杉矶\n```\n\n## Contributing\n\n1. Fork it (<https://github.com/crystal-china/myip/fork>)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Billy.Zheng](https://github.com/zw963) - creator and maintainer\n","program":{"html_id":"myip/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"locations":[],"repository_name":"myip","program":true,"enum":false,"alias":false,"const":false,"class_methods":[{"html_id":"from_url(url:String,follow:Bool=false):Lexbor::Parser-class-method","name":"from_url","abstract":false,"args":[{"name":"url","external_name":"url","restriction":"String"},{"name":"follow","default_value":"false","external_name":"follow","restriction":"Bool"}],"args_string":"(url : String, follow : Bool = false) : Lexbor::Parser","args_html":"(url : String, follow : Bool = <span class=\"n\">false</span>) : Lexbor::Parser","location":{"filename":"src/myip.cr","line_number":9,"url":"https://github.com/crystal-china/myip/blob/a6ffd2c76c59bc3e928f84d1e6330daeee1b7340/src/myip.cr#L9"},"def":{"name":"from_url","args":[{"name":"url","external_name":"url","restriction":"String"},{"name":"follow","default_value":"false","external_name":"follow","restriction":"Bool"}],"return_type":"Lexbor::Parser","visibility":"Public","body":"begin\n response = HTTP::Client.get(url)\n if response.status_code == 200\n Lexbor::Parser.new(response.body)\n else\n if follow && (response.status_code == 301)\n from_url(response.headers[\"Location\"], follow: true)\n else\n raise(ArgumentError.new(\"Host returned #{response.status_code}\"))\n end\n end\nrescue Socket::Error\n raise(Socket::Error.new(\"Host #{url} cannot be fetched\"))\nend"}},{"html_id":"get_ip_from_ib_sb(chan)-class-method","name":"get_ip_from_ib_sb","abstract":false,"args":[{"name":"chan","external_name":"chan","restriction":""}],"args_string":"(chan)","args_html":"(chan)","location":{"filename":"src/myip.cr","line_number":22,"url":"https://github.com/crystal-china/myip/blob/a6ffd2c76c59bc3e928f84d1e6330daeee1b7340/src/myip.cr#L22"},"def":{"name":"get_ip_from_ib_sb","args":[{"name":"chan","external_name":"chan","restriction":""}],"visibility":"Public","body":"spawn do\n begin\n url = \"https://api.ip.sb/geoip\"\n response = HTTP::Client.get(url)\n result = JSON.parse(response.body)\n io = IO::Memory.new\n PrettyPrint.format(result, io, 79)\n io.rewind\n chan.send({\"ip.sb/geoip:\", io.gets_to_end})\n rescue Socket::Error\n STDERR.puts(\"visit #{url} failed, please check internet connection.\")\n rescue ArgumentError\n STDERR.puts(\"#{url} return 500\")\n rescue ex\n STDERR.puts(ex.message)\n end\nend"}},{"html_id":"get_ip_from_ip111(chan)-class-method","name":"get_ip_from_ip111","abstract":false,"args":[{"name":"chan","external_name":"chan","restriction":""}],"args_string":"(chan)","args_html":"(chan)","location":{"filename":"src/myip.cr","line_number":58,"url":"https://github.com/crystal-china/myip/blob/a6ffd2c76c59bc3e928f84d1e6330daeee1b7340/src/myip.cr#L58"},"def":{"name":"get_ip_from_ip111","args":[{"name":"chan","external_name":"chan","restriction":""}],"visibility":"Public","body":"begin\n ip111_url = \"http://www.ip111.cn\"\n doc = from_url(ip111_url, follow: true)\n iframe = (doc.nodes(\"iframe\")).map do |node|\n spawn do\n begin\n url = (node.attribute_by(\"src\")).not_nil!\n ip = (from_url(url)).body!.tag_text.strip\n title = (node.parent!.parent!.parent!.css(\".card-header\")).first.tag_text.strip\n chan.send({\"ip111.cn:#{title}:\", ip})\n rescue Socket::Error\n STDERR.puts(\"visit #{url} failed, please check internet connection.\")\n rescue ArgumentError\n STDERR.puts(\"#{url} return 500\")\n rescue ex\n STDERR.puts(ex.message)\n end\n end\n end\n {doc, iframe.size}\nrescue Socket::Error\n STDERR.puts(\"visit #{ip111_url} failed, please check internet connection.\")\n exit\nrescue ArgumentError\n STDERR.puts(\"#{ip111_url} return 500\")\n exit\nrescue ex\n STDERR.puts(ex.message)\n exit\nend"}},{"html_id":"get_ip_from_ip138(chan)-class-method","name":"get_ip_from_ip138","abstract":false,"args":[{"name":"chan","external_name":"chan","restriction":""}],"args_string":"(chan)","args_html":"(chan)","location":{"filename":"src/myip.cr","line_number":40,"url":"https://github.com/crystal-china/myip/blob/a6ffd2c76c59bc3e928f84d1e6330daeee1b7340/src/myip.cr#L40"},"def":{"name":"get_ip_from_ip138","args":[{"name":"chan","external_name":"chan","restriction":""}],"visibility":"Public","body":"spawn do\n begin\n url = \"http://www.ip138.com\"\n doc = from_url(url, follow: true)\n ip138_url = (doc.css(\"iframe\")).first.attribute_by(\"src\")\n url = \"http:#{ip138_url}\"\n doc = from_url(url)\n chan.send({\"ip138.com:\", (doc.css(\"body p\")).first.tag_text.strip})\n rescue Socket::Error\n STDERR.puts(\"visit #{url} failed, please check internet connection.\")\n rescue ArgumentError\n STDERR.puts(\"#{url} return 500\")\n rescue ex\n STDERR.puts(ex.message)\n end\nend"}}],"types":[{"html_id":"myip/Myip","path":"Myip.html","kind":"module","full_name":"Myip","name":"Myip","abstract":false,"locations":[{"filename":"src/myip/version.cr","line_number":1,"url":"https://github.com/crystal-china/myip/blob/a6ffd2c76c59bc3e928f84d1e6330daeee1b7340/src/myip/version.cr#L1"}],"repository_name":"myip","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"VERSION","name":"VERSION","value":"{{ (`shards version \\\"/home/runner/work/myip/myip/src/myip\\\"`).chomp.stringify }}"}]}]}} | ||
{"repository_name":"myip","body":"# myip\n\n返回本机的公网 IP 以及访问外网的公网 IP,使用 http:/www.ip111.cn 以及 http://www.ip138.com 提供的服务。\n查看[文档](https://crystal-china.github.io/myip/)获取更多帮助\n\n```sh\n ╰─ $ bin/myip \nip111.cn:从国内测试:123.123.123.123 中国 北京市\nip138.com:您的iP地址是:[123.123.123.123 ] 来自:中国北京市西城区 联通\nip111.cn:从国外测试:111.111.111.111 美国 洛杉矶\nip111.cn:从谷歌测试:111.111.111.111 美国 洛杉矶\n```\n\n## Contributing\n\n1. Fork it (<https://github.com/crystal-china/myip/fork>)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Billy.Zheng](https://github.com/zw963) - creator and maintainer\n","program":{"html_id":"myip/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"locations":[],"repository_name":"myip","program":true,"enum":false,"alias":false,"const":false,"class_methods":[{"html_id":"from_url(url:String,follow:Bool=false):Lexbor::Parser-class-method","name":"from_url","abstract":false,"args":[{"name":"url","external_name":"url","restriction":"String"},{"name":"follow","default_value":"false","external_name":"follow","restriction":"Bool"}],"args_string":"(url : String, follow : Bool = false) : Lexbor::Parser","args_html":"(url : String, follow : Bool = <span class=\"n\">false</span>) : Lexbor::Parser","location":{"filename":"src/myip.cr","line_number":9,"url":"https://github.com/crystal-china/myip/blob/v0.4.4/src/myip.cr#L9"},"def":{"name":"from_url","args":[{"name":"url","external_name":"url","restriction":"String"},{"name":"follow","default_value":"false","external_name":"follow","restriction":"Bool"}],"return_type":"Lexbor::Parser","visibility":"Public","body":"begin\n response = HTTP::Client.get(url)\n if response.status_code == 200\n Lexbor::Parser.new(response.body)\n else\n if follow && (response.status_code == 301)\n from_url(response.headers[\"Location\"], follow: true)\n else\n raise(ArgumentError.new(\"Host returned #{response.status_code}\"))\n end\n end\nrescue Socket::Error\n raise(Socket::Error.new(\"Host #{url} cannot be fetched\"))\nend"}},{"html_id":"get_ip_from_ib_sb(chan)-class-method","name":"get_ip_from_ib_sb","abstract":false,"args":[{"name":"chan","external_name":"chan","restriction":""}],"args_string":"(chan)","args_html":"(chan)","location":{"filename":"src/myip.cr","line_number":22,"url":"https://github.com/crystal-china/myip/blob/v0.4.4/src/myip.cr#L22"},"def":{"name":"get_ip_from_ib_sb","args":[{"name":"chan","external_name":"chan","restriction":""}],"visibility":"Public","body":"spawn do\n begin\n url = \"https://api.ip.sb/geoip\"\n response = HTTP::Client.get(url)\n result = JSON.parse(response.body)\n io = IO::Memory.new\n PrettyPrint.format(result, io, 79)\n io.rewind\n chan.send({\"ip.sb/geoip:\", io.gets_to_end})\n rescue Socket::Error\n STDERR.puts(\"visit #{url} failed, please check internet connection.\")\n rescue ArgumentError\n STDERR.puts(\"#{url} return 500\")\n rescue ex\n STDERR.puts(ex.message)\n end\nend"}},{"html_id":"get_ip_from_ip111(chan)-class-method","name":"get_ip_from_ip111","abstract":false,"args":[{"name":"chan","external_name":"chan","restriction":""}],"args_string":"(chan)","args_html":"(chan)","location":{"filename":"src/myip.cr","line_number":58,"url":"https://github.com/crystal-china/myip/blob/v0.4.4/src/myip.cr#L58"},"def":{"name":"get_ip_from_ip111","args":[{"name":"chan","external_name":"chan","restriction":""}],"visibility":"Public","body":"begin\n ip111_url = \"http://www.ip111.cn\"\n doc = from_url(ip111_url, follow: true)\n iframe = (doc.nodes(\"iframe\")).map do |node|\n spawn do\n begin\n url = (node.attribute_by(\"src\")).not_nil!\n ip = (from_url(url)).body!.tag_text.strip\n title = (node.parent!.parent!.parent!.css(\".card-header\")).first.tag_text.strip\n chan.send({\"ip111.cn:#{title}:\", ip})\n rescue Socket::Error\n STDERR.puts(\"visit #{url} failed, please check internet connection.\")\n rescue ArgumentError\n STDERR.puts(\"#{url} return 500\")\n rescue ex\n STDERR.puts(ex.message)\n end\n end\n end\n {doc, iframe.size}\nrescue Socket::Error\n STDERR.puts(\"visit #{ip111_url} failed, please check internet connection.\")\n exit\nrescue ArgumentError\n STDERR.puts(\"#{ip111_url} return 500\")\n exit\nrescue ex\n STDERR.puts(ex.message)\n exit\nend"}},{"html_id":"get_ip_from_ip138(chan)-class-method","name":"get_ip_from_ip138","abstract":false,"args":[{"name":"chan","external_name":"chan","restriction":""}],"args_string":"(chan)","args_html":"(chan)","location":{"filename":"src/myip.cr","line_number":40,"url":"https://github.com/crystal-china/myip/blob/v0.4.4/src/myip.cr#L40"},"def":{"name":"get_ip_from_ip138","args":[{"name":"chan","external_name":"chan","restriction":""}],"visibility":"Public","body":"spawn do\n begin\n url = \"http://www.ip138.com\"\n doc = from_url(url, follow: true)\n ip138_url = (doc.css(\"iframe\")).first.attribute_by(\"src\")\n url = \"http:#{ip138_url}\"\n doc = from_url(url)\n chan.send({\"ip138.com:\", (doc.css(\"body p\")).first.tag_text.strip})\n rescue Socket::Error\n STDERR.puts(\"visit #{url} failed, please check internet connection.\")\n rescue ArgumentError\n STDERR.puts(\"#{url} return 500\")\n rescue ex\n STDERR.puts(ex.message)\n end\nend"}}],"types":[{"html_id":"myip/Myip","path":"Myip.html","kind":"module","full_name":"Myip","name":"Myip","abstract":false,"locations":[{"filename":"src/myip/version.cr","line_number":1,"url":"https://github.com/crystal-china/myip/blob/v0.4.4/src/myip/version.cr#L1"}],"repository_name":"myip","program":false,"enum":false,"alias":false,"const":false,"constants":[{"id":"VERSION","name":"VERSION","value":"{{ (`shards version \\\"/home/runner/work/myip/myip/src/myip\\\"`).chomp.stringify }}"}]}]}} |
Oops, something went wrong.