白嫖怪

github带善人又来发福利了

CodeSpace是Github提供的基于CodeServer的在线开发环境,相当于在vscode web提供一个远程开发环境,白嫖一个IDE加调试环境。

这就是典型的万物都能上云

不过在白嫖怪眼里就是一个高配Azure server(4C8G+100G),用来代理啊,下载啊,挖矿啊啊

开发什么的是不可能,想到的玩法就三点,滥用滥用还是滥用......

以上都上开玩笑的捏。

我们回归正题,简单对github codespace做一个用法介绍和体验

提前环境准备

  1. 使用工具: VS Code
  2. 一枚Github账号(建议滥用的申请一个新号)
  3. 申请github codespace资格(https://github.com/features/codespaces/signup)在本文发文时,此资格个人版是不需要收费的,无实例使用时间限制,team版则需要付费开启,基本都是秒申请大概4-5分钟就会发送激活邮件

连接codespace

  1. 随便创建一个仓库或者fork一个仓库
  2. 见如下图:
选择自定义配置
最好选择southeast asia(新加坡)
等待设置成功

3. 等待设置成功后,会自动跳转到vscode web,这就说明codespace创建成功了,我们不需要使用web版功能限制太多,直接打开vscode desktop,安装插件搜索github codespace 插件,等待安装...

安装codespace插件

4. 左边栏打开插件,找个仓库启动codespace,这样你就拥有一个开发环境(虚拟化容器)

开启codespace
查看结果

使用方法

其实到这里基本就靠自己发挥了,相当于默认连上了一个ubuntu的虚拟化容器,这个不是kvm虚拟化,据说是去年8月申请内测的是kvm的,这个只是个容器,所以有很多限制,比如无法使用systemd,但仍有很多用途,白嫖嘛不寒蝉。

YABS测评

root ➜ ~ $ curl -sL yabs.sh | bash
# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #
#              Yet-Another-Bench-Script              #
#                     v2022-05-06                    #
# https://github.com/masonr/yet-another-bench-script #
# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #

Thu 02 Jun 2022 10:09:57 AM UTC

Basic System Information:
---------------------------------
Uptime     : 0 days, 1 hours, 57 minutes
Processor  : Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz
CPU cores  : 4 @ 2593.907 MHz
AES-NI     : ✔ Enabled
VM-x/AMD-V : ✔ Enabled
RAM        : 7.8 GiB
Swap       : 0.0 KiB
Disk       : 91.6 GiB
Distro     : Ubuntu 20.04.4 LTS
Kernel     : 5.4.0-1074-azure

fio Disk Speed Tests (Mixed R/W 50/50):
---------------------------------
Block Size | 4k            (IOPS) | 64k           (IOPS)
  ------   | ---            ----  | ----           ---- 
Read       | 12.39 MB/s    (3.0k) | 203.52 MB/s   (3.1k)
Write      | 12.40 MB/s    (3.1k) | 204.59 MB/s   (3.1k)
Total      | 24.80 MB/s    (6.2k) | 408.12 MB/s   (6.3k)
           |                      |                     
Block Size | 512k          (IOPS) | 1m            (IOPS)
  ------   | ---            ----  | ----           ---- 
Read       | 240.90 MB/s    (470) | 308.96 MB/s    (301)
Write      | 253.70 MB/s    (495) | 329.53 MB/s    (321)
Total      | 494.61 MB/s    (965) | 638.49 MB/s    (622)

iperf3 Network Speed Tests (IPv4):
---------------------------------
Provider        | Location (Link)           | Send Speed      | Recv Speed     
                |                           |                 |                
Clouvider       | London, UK (10G)          | 941 Mbits/sec   | 1.18 Gbits/sec 
Online.net      | Paris, FR (10G)           | 1.46 Gbits/sec  | 1.21 Gbits/sec 
Hybula          | The Netherlands (40G)     | 1.02 Gbits/sec  | 1.10 Gbits/sec 
Clouvider       | NYC, NY, US (10G)         | 475 Mbits/sec   | 737 Mbits/sec  
Velocity Online | Tallahassee, FL, US (10G) | busy            | busy           
Clouvider       | Los Angeles, CA, US (10G) | 700 Mbits/sec   | 1.06 Gbits/sec 

Geekbench 5 Benchmark Test:
---------------------------------
Test            | Value                         
                |                               
Single Core     | 910                           
Multi Core      | 2085                          
Full Test       | https://browser.geekbench.com/v5/cpu/15254362

看这yabs简直就是一个美滋滋的f4s

用作proxy

因为codespace使用nginx的http和https转发做穿透,所以不能使用hysteria这种双边加速的协议,可以使用ws+tls来使用测试

这个脚本可以安装vmess+ws,剩下的tls交给github codespace加密

#!/bin/bash
# one key xray
rm -rf xray xray-linux-64.zip
wget https://github.com/XTLS/Xray-core/releases/latest/download/xray-linux-64.zip
unzip -d xray xray-linux-64.zip
rm -rf xray-linux-64.zip
cat>xray/config.json<<EOF
{
    "log": {
        "loglevel": "error"
    },
    "routing": {
        "domainStrategy": "AsIs",
        "rules": [
            {
                "type": "field",
                "ip": [
                    "geoip:private"
                ],
                "outboundTag": "block"
            }
        ]
    },
    "inbounds": [
        {
            "listen": "0.0.0.0",
            "port": 80,
            "protocol": "vmess",
            "settings": {
                "clients": [
                    {
                        "id": "ffffffff-ffff-ffff-ffff-ffffffffffff"
                    }
                ]
            },
            "streamSettings": {
                "network": "ws",
                "wsSettings": {
                    "path": "/genws"
                }
            }
        }
    ],
    "outbounds": [
        {
            "protocol": "freedom",
            "tag": "direct"
        },
        {
            "protocol": "blackhole",
            "tag": "block"
        }
    ]
}
EOF
kill -9 $(ps -ef | grep xray | grep -v grep | awk '{print $2}')
./xray/xray &
sleep 3
clear
echo done

然后就能连接了

结语

到这里介绍基本就结束了,虽然跳过很多地方,但是无伤大雅

github codespace虽然目前对个人不收费,处于测试阶段,所以我们不得以后如何,先试用。

希望不要被白嫖乖乖拿去攻击什么的,且用且珍惜吧

参考

  1. doc
  2. projectX