commit 81ac90c68e86316b8a6916f53cc6221c96618d82 Author: Kumi Date: Fri Apr 12 19:52:23 2024 +0200 feat: Launch MyIP.Coffee web service Introduced a new web service, MyIP.Coffee, for displaying client IP addresses. This update includes: - MIT License addition for open-source usage. - README for setup instructions and project overview. - PHP script and nginx configs to support IP address retrieval. - Basic website structure with HTML, CSS, and JavaScript to display IPv4 and IPv6 addresses on load. This service aims to provide a user-friendly platform for clients to easily find their public IP addresses, supporting both IPv4 and IPv6 with a focus on simplicity and efficiency. Future improvements may include enhanced IP detection and custom user settings. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8089469 --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2024 Private.coffee Team + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..025e415 --- /dev/null +++ b/README.md @@ -0,0 +1,34 @@ +# MyIP.Coffee + +MyIP.Coffee is a simple web service that returns the IP address of the client making the request. + +## Setup + +There are two components to this project, the website and the endpoint that returns the IP address. + +The endpoint runs on https://ipv4.myip.coffee and https://ipv6.myip.coffee. The IPv4 endpoint only has an A record, while the IPv6 endpoint has both only an AAAA record. + +### nginx + +If you use nginx, you don't need the endpoint. You can use the following configuration to return the IP address of the client: + +```nginx +server { + listen 80; + listen [::]:80; + + server_name ipv4.myip.coffee ipv6.myip.coffee; + + location / { + return 200 "$remote_addr"; + } +} +``` + +### PHP + +As our web hosting solution comes with PHP, there is a PHP script in [endpoint/index.php](endpoint/index.php) that just returns the IP address of the client. It is trivial to implement this in other languages, so this is left as an exercise to the reader. + +## License + +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. diff --git a/endpoint/index.php b/endpoint/index.php new file mode 100644 index 0000000..07f957b --- /dev/null +++ b/endpoint/index.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..ae5d678 --- /dev/null +++ b/index.html @@ -0,0 +1,57 @@ + + + + + + Welcome to MyIP.Coffee + + + +
+
+

MyIP.Coffee

+ +
+
+
+
+

Discover Your IP Address Instantly

+

Fast, reliable, and coffee-powered. Your public IP addresses displayed below:

+
+
+
+
+
+
+

IPv4 Address

+

Loading...

+
+
+

IPv6 Address

+

Loading...

+
+
+
+

About MyIP.Coffee

+

MyIP.Coffee was brewed with the idea of providing internet users a quick way to check their public IPv4 and IPv6 addresses. Whether you're troubleshooting network issues, setting up a server, or just curious, our site serves up your IP addresses without any fuss or frills.

+
+
+

Programmatical use

+

You can get your current IP addresses from https://ipv4.myip.coffee and https://ipv6.myip.coffee.

+
+
+
+ + + + \ No newline at end of file diff --git a/script.js b/script.js new file mode 100644 index 0000000..9f4af3b --- /dev/null +++ b/script.js @@ -0,0 +1,21 @@ +function getMyIP() { + fetch('https://ipv4.myip.coffee') + .then(response => response.text()) + .then(ipv4 => document.getElementById('ipv4').textContent = ipv4) + .catch(err => { + console.log(err); + document.getElementById('ipv6').textContent = `Not available!` + }); + + fetch('https://ipv6.myip.coffee') + .then(response => response.text()) + .then(ipv6 => document.getElementById('ipv6').textContent = ipv6) + .catch(err => { + console.log(err); + document.getElementById('ipv6').textContent = `Not available!` + }); +} + +document.addEventListener('DOMContentLoaded', () => { + getMyIP(); +}); \ No newline at end of file diff --git a/style.css b/style.css new file mode 100644 index 0000000..5d1becd --- /dev/null +++ b/style.css @@ -0,0 +1,165 @@ +/* Reset and base styles */ +* { + box-sizing: border-box; + margin: 0; + padding: 0; +} + +body { + font-family: 'Roboto', sans-serif; + background-color: #f7f7f7; + color: #333; + line-height: 1.6; +} + +a { + color: #5d5d5d; + text-decoration: none; +} + +a:hover { + color: #333; +} + +.container { + width: 90%; + max-width: 1200px; + margin: auto; + overflow: hidden; +} + +/* Header */ +header { + background-color: #fff; + box-shadow: 0 2px 4px rgba(0,0,0,0.1); + padding: 20px 0; +} + +header h1 { + color: #5d5d5d; + text-align: center; + margin: 0; + font-size: 36px; +} + +header nav ul { + list-style: none; + text-align: center; + padding: 0; +} + +header nav ul li { + display: inline; + margin: 0 15px; +} + +header nav ul li a { + color: #5d5d5d; + font-weight: 700; + font-size: 18px; +} + +/* Hero Section */ +.hero { + background-color: #e8e8e8; + padding: 50px 0; + margin-bottom: 40px; +} + +.hero h2 { + text-align: center; + margin-bottom: 10px; + color: #333; + font-size: 28px; +} + +.hero p { + text-align: center; + font-size: 18px; + color: #666; +} + +/* IP Display Cards */ +.ip-display { + display: flex; + justify-content: space-around; + flex-wrap: wrap; + gap: 20px; + margin-bottom: 40px; +} + +.ip-card { + background-color: #fff; + padding: 30px 10px; + box-shadow: 0 2px 5px rgba(0,0,0,0.1); + border-radius: 8px; + flex-basis: calc(50% - 10px); + text-align: center; +} + +.ip-card h3 { + margin-bottom: 15px; + color: #5d5d5d; + font-size: 22px; +} + +.ip-card p { + font-size: 20px; + color: #333; + word-break: break-all; +} + +/* About Section */ +#about { + text-align: center; + margin-bottom: 40px; + padding: 0 20px; +} + +#about h2 { + margin-bottom: 15px; + color: #333; + font-size: 24px; +} + +#about p { + font-size: 18px; + color: #666; +} + +/* API Section */ +#api { + text-align: center; + margin-bottom: 40px; + padding: 0 20px; +} + +#api h2 { + margin-bottom: 15px; + color: #333; + font-size: 24px; +} + +#api p { + font-size: 18px; + color: #666; +} + +/* Footer */ +footer { + background-color: #fff; + box-shadow: 0 -2px 4px rgba(0,0,0,0.1); + text-align: center; + padding: 20px; + position: relative; +} + +footer p { + margin: 0; + color: #5d5d5d; +} + +footer a { + color: #5d5d5d; + font-weight: 700; +} \ No newline at end of file