Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 1.1.31 #82

Merged
merged 7 commits into from
Aug 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 44 additions & 21 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* [简体中文(Chinese Simplified)](https://github.com/yushijinhun/authlib-injector/blob/develop/README.md)

# authlib-injector
[![circle ci](https://img.shields.io/circleci/project/github/yushijinhun/authlib-injector/master.svg?style=flat-square)](https://circleci.com/gh/yushijinhun/authlib-injector/tree/master)
[![circle ci](https://img.shields.io/github/workflow/status/yushijinhun/authlib-injector/CI?style=flat-square)](https://github.com/yushijinhun/authlib-injector/actions?query=workflow%3ACI)
[![license agpl-3.0](https://img.shields.io/badge/license-AGPL--3.0-blue.svg?style=flat-square)](https://github.com/yushijinhun/authlib-injector/blob/1caea43b49a059de4f8e44f11ede06a89a43a088/LICENSE)
![language](https://img.shields.io/badge/language-java-yellow.svg?style=flat-square)
![require java 1.8+](https://img.shields.io/badge/require%20java-1.8%2B-orange.svg?style=flat-square)
Expand All @@ -24,31 +24,54 @@ gradle
Build output can be found in `build/libs`.

## Deploy
The authentication server is required to implement [Yggdrasil Server Specification](https://github.com/yushijinhun/authlib-injector/wiki/Yggdrasil-%E6%9C%8D%E5%8A%A1%E7%AB%AF%E6%8A%80%E6%9C%AF%E8%A7%84%E8%8C%83).

Configure Minecraft server with the following JVM parameter:
```
-javaagent:{/path/to/authlib-injector.jar}={API Root of Authentication Server}
-javaagent:{/path/to/authlib-injector.jar}={Authentication Server URL}
```

## Debug
### Print verbose logs
Add the following JVM parameter:
```
-Dauthlibinjector.debug={types of logs to print}
## Options
```
Types of logs:
* `launch` startup of authlib-injector
* `transform` bytecode modification
* `config` configuration fetching
* `httpd` local http server (The local http server acts as a reverse proxy between client and the remote authentication server, which allows authlib-injector to implement enhancements.)
* `authlib` logs intercepted from authlib (which contains detailed network communication)
-Dauthlibinjector.mojangNamespace={default|enabled|disabled}
Whether to enable Mojang namespace (@mojang suffix).
It's enabled by default if the authentication server does NOT send feature.no_mojang_namespace option.

Use `,` as the separator when specifying multiple types. To print all the logs, set the type to `all`.
If enabled, virtual player <username>@mojang will have the same skin as premium (Mojang) player <username>.
For example,
- /give @p minecraft:skull 1 3 {SkullOwner:"Notch@mojang"}
- /npc skin Notch@mojang
will display Notch's skin.

### Dump modified classes
Dump the modified classes to current directory with the following JVM parameter:
```
-Dauthlibinjector.dumpClass=true
```
Note that the virtual player does NOT have the same UUID as its corresponding premium player.
To distinguish virtual players from actual ones, the most significant bit of time_hi_and_version is set to 1 (see RFC 4122 section 4.1.3).
For example:
069a79f4-44e9-4726-a5be-fca90e38aaf5 Notch
069a79f4-44e9-c726-a5be-fca90e38aaf5 Notch@mojang
We use this approach because, in RFC 4122, UUID version has only 6 possible values (0~5), which means the most significant is always 0.
In fact, Mojang uses version-4 (random) UUID, so its corresponding virtual player has a version-12 UUID.

-Dauthlibinjector.mojangProxy={proxy server URL}
Use proxy when accessing Mojang authentication service.
Only SOCKS protocol is supported.
URL format: socks://<host>:<port>

-Dauthlibinjector.legacySkinPolyfill={default|enabled|disabled}
Whether to polyfill legacy skin API, namely 'GET /skins/MinecraftSkins/{username}.png'.
It's enabled by default if the authentication server does NOT send feature.legacy_skin_api option.

-Dauthlibinjector.debug (equals -Dauthlibinjector.debug=verbose,authlib)
or -Dauthlibinjector.debug={comma-separated debug options}
Available debug options:
- verbose enable verbose logging
- authlib print logs from Mojang authlib
- dumpClass dump modified classes
- printUntransformed print classes that are analyzed but not transformed, implies 'verbose'

-Dauthlibinjector.ignoredPackages={comma-separated package list}
Ignore specified packages. Classes in these packages will not be analyzed or modified.

-Dauthlibinjector.disableHttpd
Disable local HTTP server.
Features (see below) depending on local HTTP server will be unavailable:
- Mojang namespace
- Legacy skin API polyfill
```
63 changes: 43 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* **简体中文(Chinese Simplified)**

# authlib-injector
[![circle ci](https://img.shields.io/circleci/project/github/yushijinhun/authlib-injector/master.svg?style=flat-square)](https://circleci.com/gh/yushijinhun/authlib-injector/tree/master)
[![circle ci](https://img.shields.io/github/workflow/status/yushijinhun/authlib-injector/CI?style=flat-square)](https://github.com/yushijinhun/authlib-injector/actions?query=workflow%3ACI)
[![license agpl-3.0](https://img.shields.io/badge/license-AGPL--3.0-blue.svg?style=flat-square)](https://github.com/yushijinhun/authlib-injector/blob/1caea43b49a059de4f8e44f11ede06a89a43a088/LICENSE)
![language](https://img.shields.io/badge/language-java-yellow.svg?style=flat-square)
![require java 1.8+](https://img.shields.io/badge/require%20java-1.8%2B-orange.svg?style=flat-square)
Expand All @@ -24,33 +24,56 @@ gradle
构建输出位于 `build/libs` 下。

## 部署
需要服务端实现本规范中的[扩展 API](https://github.com/yushijinhun/authlib-injector/wiki/Yggdrasil-%E6%9C%8D%E5%8A%A1%E7%AB%AF%E6%8A%80%E6%9C%AF%E8%A7%84%E8%8C%83#%E6%89%A9%E5%B1%95-api)。
通过添加以下 JVM 参数来配置:
```
-javaagent:{authlib-injector.jar 的路径}={Yggdrasil 服务端的 URLAPI Root)}
-javaagent:{authlib-injector.jar 的路径}={验证服务器 URL (API 地址)}
```

## 调试
### 调试输出
添加以下 JVM 参数:
## 参数
```
-Dauthlibinjector.debug={要打印的调试信息类型}
```
调试信息类型有:
* `launch` 有关 authlib-injector 加载的
* `transform` 有关字节码修改的
* `config` 有关配置获取的
* `httpd` 有关本地 HTTP 服务器的(其负责在本地处理掉部分请求,而不是发送到 Yggdrasil 服务端)
* `authlib` 打印从 authlib 处获取的日志(其记录了网络调用的详细信息)
-Dauthlibinjector.mojangNamespace={default|enabled|disabled}
设置是否启用 Mojang 命名空间 (@mojang 后缀).
若验证服务器未设置 feature.no_mojang_namespace 选项, 则该功能默认启用.

可以指定多个类型,中间用 `,` 分隔。如果要打印以上所有调试信息,可以设置其为 `all`。
启用后, 则可以使用名为 <username>@mojang 的虚拟角色来调用对应正版角色的皮肤.
例如,
- /give @p minecraft:skull 1 3 {SkullOwner:"Notch@mojang"}
- /npc skin Notch@mojang
显示的将会是 Notch 的皮肤.

### 保存修改过的类
添加以下 JVM 参数:
```
-Dauthlibinjector.dumpClass=true
注意, 虚拟角色和对应正版角色的 UUID 是不同的. 为了将虚拟角色和正版角色区别开,
虚拟角色 UUID 中 time_hi_and_version 字段的最高位被置为 1 (见 RFC 4122 4.1.3 章节).
例如:
069a79f4-44e9-4726-a5be-fca90e38aaf5 Notch
069a79f4-44e9-c726-a5be-fca90e38aaf5 Notch@mojang
采用该方法的原因是, 在 RFC 4122 中 UUID 版本号只有 6 种可能的取值 (0~5), 版本号的最高位始终为 0.
而实际上, Mojang 使用的是版本 4 (随机) UUID, 因此其对应的虚拟角色的 UUID 版本号为 12.

-Dauthlibinjector.mojangProxy={代理服务器 URL}
设置访问 Mojang 验证服务时使用的代理, 目前仅支持 SOCKS 协议.
URL 格式: socks://<host>:<port>

-Dauthlibinjector.legacySkinPolyfill={default|enabled|disabled}
是否启用旧式皮肤 API polyfill, 即 'GET /skins/MinecraftSkins/{username}.png'.
若验证服务器未设置 feature.legacy_skin_api 选项, 则该功能默认启用.

-Dauthlibinjector.debug (等价于 -Dauthlibinjector.debug=verbose,authlib)
或 -Dauthlibinjector.debug={调试选项; 逗号分隔}
可用的调试选项:
- verbose 详细日志
- authlib 开启 Mojang authlib 的调试输出
- dumpClass 转储修改过的类
- printUntransformed 打印已分析但未修改的类; 隐含 verbose

-Dauthlibinjector.ignoredPackages={包列表; 逗号分隔}
忽略指定的包, 其中的类将不会被分析或修改.

-Dauthlibinjector.disableHttpd
禁用内建的 HTTP 服务器.
以下依赖内建 HTTP 服务器的功能将不可用:
- Mojang 命名空间
- 旧式皮肤 API polyfill
```
修改过的类文件会保存在当前目录下。

## 捐助
BMCLAPI 为 authlib-injector 提供了[下载镜像站](https://github.com/yushijinhun/authlib-injector/wiki/%E8%8E%B7%E5%8F%96-authlib-injector#bmclapi-%E9%95%9C%E5%83%8F)。如果您想要支持 authlib-injector 的开发,您可以[捐助 BMCLAPI](https://bmclapidoc.bangbang93.com/)。
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ jar {
'Implementation-Vendor': 'yushijinhun',
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
'Automatic-Module-Name': 'moe.yushi.authlibinjector',
'Premain-Class': 'moe.yushi.authlibinjector.javaagent.AuthlibInjectorPremain',
'Agent-Class': 'moe.yushi.authlibinjector.javaagent.AuthlibInjectorPremain',
'Premain-Class': 'moe.yushi.authlibinjector.Premain',
'Agent-Class': 'moe.yushi.authlibinjector.Premain',
'Can-Retransform-Classes': true,
'Can-Redefine-Classes': true,
'Git-Commit': gitInfo.gitHashFull,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 Haowei Wen <[email protected]> and contributors
* Copyright (C) 2020 Haowei Wen <[email protected]> and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
Expand Down Expand Up @@ -37,9 +37,9 @@
import moe.yushi.authlibinjector.util.JsonUtils;
import moe.yushi.authlibinjector.util.KeyUtils;

public class YggdrasilConfiguration {
public class APIMetadata {

public static YggdrasilConfiguration parse(String apiRoot, String metadataResponse) throws UncheckedIOException {
public static APIMetadata parse(String apiRoot, String metadataResponse) throws UncheckedIOException {
JSONObject response = asJsonObject(parseJson(metadataResponse));

List<String> skinDomains =
Expand All @@ -59,15 +59,15 @@ public static YggdrasilConfiguration parse(String apiRoot, String metadataRespon
.map(it -> (Map<String, Object>) new TreeMap<>(asJsonObject(it)))
.orElse(emptyMap());

return new YggdrasilConfiguration(apiRoot, unmodifiableList(skinDomains), unmodifiableMap(meta), decodedPublickey);
return new APIMetadata(apiRoot, unmodifiableList(skinDomains), unmodifiableMap(meta), decodedPublickey);
}

private String apiRoot;
private List<String> skinDomains;
private Optional<PublicKey> decodedPublickey;
private Map<String, Object> meta;

public YggdrasilConfiguration(String apiRoot, List<String> skinDomains, Map<String, Object> meta, Optional<PublicKey> decodedPublickey) {
public APIMetadata(String apiRoot, List<String> skinDomains, Map<String, Object> meta, Optional<PublicKey> decodedPublickey) {
this.apiRoot = requireNonNull(apiRoot);
this.skinDomains = requireNonNull(skinDomains);
this.meta = requireNonNull(meta);
Expand All @@ -92,7 +92,6 @@ public Optional<PublicKey> getDecodedPublickey() {

@Override
public String toString() {
return format("YggdrasilConfiguration [apiRoot={0}, skinDomains={1}, decodedPublickey={2}, meta={3}]", apiRoot, skinDomains, decodedPublickey, meta);
return format("APIMetadata [apiRoot={0}, skinDomains={1}, decodedPublickey={2}, meta={3}]", apiRoot, skinDomains, decodedPublickey, meta);
}

}
Loading