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.
This commit is contained in:
commit
81ac90c68e
6 changed files with 299 additions and 0 deletions
19
LICENSE
Normal file
19
LICENSE
Normal file
|
@ -0,0 +1,19 @@
|
|||
Copyright (c) 2024 Private.coffee Team <support@private.coffee>
|
||||
|
||||
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.
|
34
README.md
Normal file
34
README.md
Normal file
|
@ -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.
|
3
endpoint/index.php
Normal file
3
endpoint/index.php
Normal file
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
echo $_SERVER['REMOTE_ADDR'];
|
||||
?>
|
57
index.html
Normal file
57
index.html
Normal file
|
@ -0,0 +1,57 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Welcome to MyIP.Coffee</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<div class="container">
|
||||
<h1>MyIP.Coffee</h1>
|
||||
<nav>
|
||||
<ul>
|
||||
<li><a href="#ipv4">IPs</a></li>
|
||||
<li><a href="#about">About</a></li>
|
||||
<li><a href="#api">API</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
<section class="hero">
|
||||
<div class="container">
|
||||
<h2>Discover Your IP Address Instantly</h2>
|
||||
<p>Fast, reliable, and coffee-powered. Your public IP addresses displayed below:</p>
|
||||
</div>
|
||||
</section>
|
||||
<main>
|
||||
<div class="container">
|
||||
<section class="ip-display">
|
||||
<div class="ip-card"">
|
||||
<h3>IPv4 Address</h3>
|
||||
<p id="ipv4">Loading...</p>
|
||||
</div>
|
||||
<div class="ip-card">
|
||||
<h3>IPv6 Address</h3>
|
||||
<p id="ipv6">Loading...</p>
|
||||
</div>
|
||||
</section>
|
||||
<section id="about">
|
||||
<h2>About MyIP.Coffee</h2>
|
||||
<p>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.</p>
|
||||
</section>
|
||||
<section id="api">
|
||||
<h2>Programmatical use</h2>
|
||||
<p>You can get your current IP addresses from <code>https://ipv4.myip.coffee</code> and <code>https://ipv6.myip.coffee</code>.</p>
|
||||
</section>
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
<div class="container">
|
||||
<p>© 2024 Private.coffee | <a href="https://private.coffee/privacy.html">Privacy Policy</a> | <a href="https://private.coffee/legal.html">Legal Notice</a> | <a href="https://git.private.coffee/PrivateCoffee/myip.coffee">Git</a></p>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="script.js"></script>
|
||||
</body>
|
||||
</html>
|
21
script.js
Normal file
21
script.js
Normal file
|
@ -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();
|
||||
});
|
165
style.css
Normal file
165
style.css
Normal file
|
@ -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;
|
||||
}
|
Loading…
Reference in a new issue