Skip to content
This repository has been archived by the owner on Dec 18, 2021. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ZE3kr committed Jul 22, 2018
1 parent 29de0cf commit aa0f3b3
Show file tree
Hide file tree
Showing 25 changed files with 2,145 additions and 24 deletions.
92 changes: 92 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Contributing

When contributing to this repository, please first discuss the change you wish to make via issue,
email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

## Pull Request Process

1. Ensure any install or build dependencies are removed before the end of the layer when doing a
build.
2. Update the README.md with details of changes to the interface, this includes new environment
variables, exposed ports, useful file locations and container parameters.
3. Increase the version numbers in any examples files and the README.md to the new version that this
Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you
do not have permission to do that, you may request the second reviewer to merge it for you.

## Code of Conduct

### Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.

### Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

### Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

### Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

### Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [ze3kr@icloud.com](mailto:ze3kr@icloud.com). All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

### Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2017-2018 ZE3kr

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.
71 changes: 47 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,53 @@
# Cloudflare CNAME Setup

## 马上就要开源了快 Star 一下吧

This project allows [Cloudflare Hosting Partner][1] to provide a panel for customers, which allows customers to have [CNAME setup][2] for **free**.

[cf.tlo.xyz][3] is the official site installed the stable version of this panel. The software is up-to-date and you can trusted.
[查看中文版本][3]

[cf.tlo.xyz][4] is the official site installed the stable version of this panel. The software is up-to-date and you can trust.

The [beta.cf.tlo.xyz][5] is for the beta version.

## Installation

If you don’t want to use the preinstalled panel above, you can install this panel on your server. Please follow this guide.

### Requirements

+ PHP 7.0+ installed (with cURL and APCu Cache)
+ Web server (Nginx, Apache, etc.)
+ Cloudflare Partner account

### Configuration

The [beta.cf.tlo.xyz][4] is for the beta version.
Just copy `config.example.php` to `config.php` and edit it with your information.

## Features of this panel

+ Manage all your DNS records in one place. Using the [Cloudflare API v4][5], this project supports various types of DNS records.
+ Manage all your DNS records in one place. Using the [Cloudflare API v4][6], this project supports various types of DNS records.
+ Advanced Analytics. You can see the analytics report for the **previous year**, rather than a month.
+ NS setup is supported. This panel provide NS setup information so you can switch to Cloudflare DNS at any time. The DNSSEC feature is also supported.
+ NS setup is supported. This panel provides NS setup information so you can switch to Cloudflare DNS at any time. The DNSSEC feature is also supported.
+ IP setup is supported. This service provides the anycast IPv4 and IPv6 of the CDN. You can use this service for the root domain safely.
+ Supports multi languages.
+ Supports multi-languages.

## How to switch to this panel from NS setup

1. Backup your existing record
2. Switch your domain to another DNS services and restore the DNS record (Optional)
3. Delete your domain on Cloudflare (Might have a down time if you have not down step 2)
3. Delete your domain on Cloudflare (Might have a downtime if you have not done step 2)
4. Re-add your domain on the panel
5. Setup the DNS records on this panel
6. Delete the existing DNS record and CNAME to Cloudflare (Only if you have done step 2)

## Advantages for CNAME setup

+ You can use any DNS provider you like, which is much more flexible.
+ Use Cloudflare CDN as a backend server or use multiple CDNs.
+ Support fourth-level subdomain SSL for free! For example, the domain like `dev.project.example.com` is ready for HTTPS. This is because for CNAME setup, the Cloudflare issues the [SSL for SaaS][6], which issues the SSL separately for each sub-domain immediately.
+ Use Cloudflare CDN as a backup server or use multiple CDNs.
+ Support fourth-level subdomain SSL for free! For example, the domain like `dev.project.example.com` is ready for HTTPS. This is because, for CNAME setup, the Cloudflare issues the [SSL for SaaS][7], which issues the SSL separately for each sub-domain immediately.

## Advantages when you using Cloudflare
## Advantages when you use Cloudflare

**You don’t need to install any software on your backend**. Just configure your backend server information on the panel, delete the existing DNS record and CNAME to Cloudflare or switch to Cloudflare DNS, and you are done!
**You don’t need to install any software on your origin**. Just configure your origin server information on the panel, delete the existing DNS record and CNAME to Cloudflare or switch to Cloudflare DNS, and you are done!

+ Unmetered Mitigation of DDoS
+ Global CDN. Your website will be much faster.
Expand All @@ -43,27 +57,36 @@ The [beta.cf.tlo.xyz][4] is for the beta version.

## Screenshot

![Screenshot1](https://cdn.landcement.com/uploads/cloudflare/Screenshot1.png)
![Screenshot2](https://cdn.landcement.com/uploads/cloudflare/Screenshot2.png)
![Screenshot3](https://cdn.landcement.com/uploads/cloudflare/Screenshot3.png)
![Screenshot4](https://cdn.landcement.com/uploads/cloudflare/Screenshot4.png)
![Screenshot1][image-1]
![Screenshot2][image-2]
![Screenshot3][image-3]
![Screenshot4][image-4]

## Open sourced softwares used in this project
## Open sourced software used in this project

This project was based on a [HOSTLOC topic](http://www.hostloc.com/thread-386441-1-1.html).
This project was based on a [HOSTLOC topic][8].

+ Amaze UI by Amaze UI Team | Licensed under MIT
+ Net_DNS2 by Mike Pultz <mike@mikepultz.com> | Licensed under BSD-3-Clause
+ Net\_DNS2 by Mike Pultz [mike@mikepultz.com][9] | Licensed under BSD-3-Clause
+ PHPMailer by Free Software Foundation, Inc. | Lincesed under GNU Lesser General Public License v2.1
+ Cloudflare SDK by Cloudflare | Licensed under BSD-3-Clause
+ Chart.js by Nick Downie | Licensed under the MIT license
+ Guzzle by Michael Dowling <mtdowling@gmail.com> | Licensed under MIT
+ Guzzle by Michael Dowling [mtdowling@gmail.com][10] | Licensed under MIT
+ PSR Http Message by Framework Interoperability Group | Licensed under MIT
+ Composer | Licensed under MIT

[1]: https://www.cloudflare.com/partners/hosting-provider/
[2]: https://support.cloudflare.com/hc/en-us/articles/200168706-How-do-I-do-CNAME-setup-
[3]: https://cf.tlo.xyz
[4]: https://beta.cf.tlo.xyz
[5]: https://api.cloudflare.com/
[6]: https://www.cloudflare.com/ssl-for-saas-providers/
[3]: https://github.com/ZE3kr/Cloudflare-CNAME-Setup/blob/master/README.zh.md
[4]: https://cf.tlo.xyz
[5]: https://beta.cf.tlo.xyz
[6]: https://api.cloudflare.com/
[7]: https://www.cloudflare.com/ssl-for-saas-providers/
[8]: http://www.hostloc.com/thread-386441-1-1.html
[9]: mailto:mike@mikepultz.com
[10]: mailto:mtdowling@gmail.com

[image-1]: https://cdn.landcement.com/uploads/cloudflare/Screenshot1.png
[image-2]: https://cdn.landcement.com/uploads/cloudflare/Screenshot2.png
[image-3]: https://cdn.landcement.com/uploads/cloudflare/Screenshot3.png
[image-4]: https://cdn.landcement.com/uploads/cloudflare/Screenshot4.png
89 changes: 89 additions & 0 deletions README.zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Cloudflare CNAME 接入

[Cloudflare Hosting Partner][1] 可以使用此项目为用户提供一个可视化的面板,可以让用户免费的使用 [CNAME 接入][2]

[cf.tlo.xyz][3] 是安装了这个面板的最新稳定版的官方网站,值得你的信任。

[beta.cf.tlo.xyz][4] 安装了最新的测试版。

## 安装

如果你不想使用上述已经安装好了的面板,你可以在自己的服务器上安装。请参考下方指南。

### 需求

+ PHP 7.0+ (需要 cURL 和 APCu Cache 插件)
+ 网页服务器 (Nginx, Apache, 等)
+ Cloudflare Partner 账户

### 配置

只需要拷贝 `config.example.php``config.php`,然后对其编辑即可。

## 此面板的特性

+ 管理你的所有 DNS 记录。此面板使用了 [Cloudflare API v4][5],所以支持各种格式的 DNS 记录。
+ 高级统计。你可以查看**过去一整年的统计信息**,而不仅仅是一个月。
+ 同时支持 NS 接入。此面板提供了 NS 接入信息,所以你可以随时切换到 Cloudflare DNS。此外,这个面板也支持 DNSSEC。
+ 同时支持 IP 接入。你可以看到 DNS 的 Anycast IPv4 和 IPv6 信息,这样你可以安全地在根域名下使用第三方 DNS。
+ 支持多种语言。

## 如何从 NS 接入转成从这个面板接入?

1. 备份现有域名的 DNS 记录。
2. 从备份中恢复,切换到另一个 DNS 解析商。(可选的)
3. 在 Cloudflare 上删除你的域名 (如果你没有完成第二部则可能会导致你的网站在一段时间内无法访问)
4. 在这个面板上重新添加域名。
5. 在这个面板上配置 DNS 记录。
6. 删除已有的 DNS 记录然后重新添加 CDN 的记录。(如果你在步骤二中切换到了另一个 DNS 解析商)

## CNAME 接入的好处

+ 更加灵活,因为你可以使用任何一个 DNS 提供商。
+ 将 Cloudflare 作为一个备份服务器,或者使用多个 CDN。
+ 可以免费支持四级域名下的 SSL!例如像 `dev.project.example.com` 这样的域名,Cloudflare 也会自动签发 SSL 证书,这是因为 CNAME 接入签发的是 [SSL for SaaS][6],它会自动的为每一个字域名签发证书。

## 使用 Cloudflare 的好处

**你不需要在服务器端安装任何软件**。只需要在这个面板配置好源站服务器信息,删除已有记录并 CNAME 到 Cloudflare 的服务器,或者直接使用 Cloudflare DNS 即可!

+ 无限 DDOS 防御
+ 全球 CDN。你的网站会因此变得更快。
+ I'm Under Attack™ 模式可以自动清洗恶意流量。
+ Always Online ™ 让你的网站永远在线。
+ 支持 Page Rules. 你可以自定义缓存规则,配置 301 或 302 跳转以及更多。

## 屏幕截图

![Screenshot1][image-1]
![Screenshot2][image-2]
![Screenshot3][image-3]
![Screenshot4][image-4]

## Open sourced software used in this project

This project was based on a [HOSTLOC topic][7].

+ Amaze UI by Amaze UI Team | Licensed under MIT
+ Net\_DNS2 by Mike Pultz [mike@mikepultz.com][8] | Licensed under BSD-3-Clause
+ PHPMailer by Free Software Foundation, Inc. | Lincesed under GNU Lesser General Public License v2.1
+ Cloudflare SDK by Cloudflare | Licensed under BSD-3-Clause
+ Chart.js by Nick Downie | Licensed under the MIT license
+ Guzzle by Michael Dowling [mtdowling@gmail.com][9] | Licensed under MIT
+ PSR Http Message by Framework Interoperability Group | Licensed under MIT
+ Composer | Licensed under MIT

[1]: https://www.cloudflare.com/partners/hosting-provider/
[2]: https://support.cloudflare.com/hc/en-us/articles/200168706-How-do-I-do-CNAME-setup-
[3]: https://cf.tlo.xyz
[4]: https://beta.cf.tlo.xyz
[5]: https://api.cloudflare.com/
[6]: https://www.cloudflare.com/ssl-for-saas-providers/
[7]: http://www.hostloc.com/thread-386441-1-1.html
[8]: mailto:mike@mikepultz.com
[9]: mailto:mtdowling@gmail.com

[image-1]: https://cdn.landcement.com/uploads/cloudflare/Screenshot1.png
[image-2]: https://cdn.landcement.com/uploads/cloudflare/Screenshot2.png
[image-3]: https://cdn.landcement.com/uploads/cloudflare/Screenshot3.png
[image-4]: https://cdn.landcement.com/uploads/cloudflare/Screenshot4.png
71 changes: 71 additions & 0 deletions actions/add.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php
/*
* Using Partner API to add domain for CNAME or NS setup.
*/

if(!isset($tlo_id)){ exit; }

$msg = '';
if(isset($_POST['submit']))
{
$zone_name = $_POST['domain'];
if(isset($_POST['type']) && $_POST['type'] == 'ns') {
/* NS setup */
$res = $cloudflare->zoneSet_full($zone_name);
if ( $res['result'] == 'success' ) {
$msg = _('Success').', <a target="_blank" href="https://www.cloudflare.com/a/overview/'.$zone_name.'">'._('Go to console').'</a>. ';
exit($msg);
} else {
if (isset($res['msg'])) {
exit($res['msg']);
} else {
print_r($res);
exit;
}
}
}
/*
* We need `_tlo-wildcard` subdomain to support anycast IP information.
*/
$res = $cloudflare->zoneSet($zone_name,'example.com','_tlo-wildcard');
if ( $res['result'] == 'success' ) {
$zones = new \Cloudflare\API\Endpoints\Zones($adapter);
try {
$zoneID = $zones->getZoneID($zone_name);
} catch (Exception $e){
echo 'Caught exception: ', $e->getMessage(), "\n";
}

$dns = new \Cloudflare\API\Endpoints\DNS($adapter);
$dnsresult = $dns->listRecords($zoneID)->result;
/*
* Delete @ and `www` record to make this zone fresh.
*/
foreach ($dnsresult as $record) {
if($record->name == $zone_name){
$dns->deleteRecord($zoneID, $record->id);
} elseif($record->name == 'www.'.$zone_name) {
$dns->deleteRecord($zoneID, $record->id);
}
}
$msg = _('Success').', <a href="?action=zones&amp;domain='.$zone_name.'&amp;zoneid='.$zoneID.'">'._('Go to console').'</a>. ';
exit($msg);
} else {
$msg = $res['msg'];
}
}
echo $msg;
?>
<form method="POST" action="" class="am-form am-form-horizontal">
<div class="am-form-group">
<label for="doc-ipt-3" class="am-u-sm-2 am-form-label"><?php echo _('Domain'); ?></label>
<div class="am-u-sm-10">
<input type="text" id="doc-ipt-3" name="domain" placeholder="<?php echo _('Please enter your domain'); ?>">
</div>
</div>
<div class="am-form-group">
<div class="am-u-sm-10 am-u-sm-offset-2">
<button type="submit" name="submit" class="am-btn am-btn-default"><?php echo _('Submit'); ?></button>
</div>
</div>
</form>
Loading

0 comments on commit aa0f3b3

Please sign in to comment.