代码依赖 Node.js 运行环境以及 Python 运行环境。
下面将安装 Node.js 和 Python 运行时:
| #!/bin/sh | |
| # | |
| # Amazon EC2 user-data file for automatic configuration of IPsec/L2TP VPN | |
| # on a Ubuntu server instance. Tested with 14.04 (Trusty) AND 12.04 (Precise). | |
| # With minor modifications, this script *can also be used* on dedicated servers | |
| # or any KVM- or XEN-based Virtual Private Server (VPS) from other providers. | |
| # | |
| # For detailed instructions, please see: | |
| # https://blog.ls20.com/ipsec-l2tp-vpn-auto-setup-for-ubuntu-12-04-on-amazon-ec2/ | |
| # Original post by Thomas Sarlandie: |
| #!/usr/bin/env python | |
| #-*- coding:utf-8 -*- | |
| """ | |
| IPv4 addresses to a 32-bit integer value | |
| Document: https://en.wikipedia.org/wiki/IPv4#Address_representations | |
| IPv4 addresses may be in any notation expressing a 32-bit integer value, |
| #!/usr/bin/env nodejs | |
| // -*- mode: js -*- | |
| /* | |
| NodeJS: | |
| WEB: https://nodejs.org/ | |
| Package: https://www.npmjs.com/ | |
| */ |
| #!/usr/bin/env fibjs | |
| // -*- mode: js -*- | |
| /* | |
| Fibjs: | |
| web: http://fibjs.org/ | |
| Package: http://fpmjs.org/ | |
| Install: | |
| 1. $ npm install fibjs |
| <html> | |
| <head> | |
| <script type="text/javascript"> | |
| // 使用方法: | |
| // 页面加载完毕后,打开 浏览器控制台,调用函数 `get_file_content()` 即可以看到数据。 | |
| function chr (code){ | |
| return String.fromCharCode(parseInt(code)); | |
| } | |
| function ord(s){ | |
| return s.charCodeAt(0); |
| #!/usr/bin/env python | |
| #coding: utf8 | |
| import base64 | |
| import hashlib | |
| import binascii | |
| from Crypto import Random | |
| from Crypto.Cipher import AES | |
| from os import urandom |
| #!/usr/bin/env python | |
| #coding: utf8 | |
| import json, re | |
| import requests | |
| try: | |
| from bs4 import BeautifulSoup | |
| except: |
| def rgb_to_ycbcr(r, g, b): | |
| assert(255>=r) | |
| assert(255>=g) | |
| assert(255>=b) | |
| y = 0.299*r + 0.587*g + 0.114*b | |
| cb = 128 - 0.168736*r - 0.331364*g + 0.5*b | |
| cr = 128 + 0.5*r - 0.418688*g - 0.081312*b | |
| return int(y), int(cb), int(cr) |