# 프록시 프로토콜

## 개요

<figure><img src="https://209055715-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVkJmXC0Zry3o8BxDQbFQ%2Fuploads%2F0ORbqHBARa1UD0EcqzMs%2Fimage.png?alt=media&#x26;token=47ed6bc4-ec8e-451a-8ff9-ffadd5f8cf03" alt=""><figcaption></figcaption></figure>

프록시 프로토콜(Proxy Protocol)은\
Wrdefense+를 통해서 플레이어가  접속할때\
**실제 접속한 클라이언트의 IP 주소를 서버에 전달해 주는 방식**이에요.

일반적인환경에서는,\
서버 로그에 실제 유저 IP가 아닌 Wrdefense+ **서버의 IP**만 표시됩니다.\
이로 인해 IP 기반 기능이 제대로 동작하지 않는 문제가 발생할 수  있어요.

## 중요 정보

프록시 프로토콜은 네트워크 설정만으로 자동 적용되지 않아요!

프록시 프로토콜을 사용하는 경우,\
별도로 **프록시 프로토콜을 인식하도록 설정해주셔야해요.**&#x20;

일부 사용 환경에서는, 접속 오류가 발생할수도 있어요.

{% content-ref url="proxyproto/paper" %}
[paper](https://docs.weirdhost.xyz/plus/proxyproto/paper)
{% endcontent-ref %}

{% content-ref url="proxyproto/forge" %}
[forge](https://docs.weirdhost.xyz/plus/proxyproto/forge)
{% endcontent-ref %}

{% content-ref url="../minecraft/version/fabric" %}
[fabric](https://docs.weirdhost.xyz/minecraft/version/fabric)
{% endcontent-ref %}

## 프록시 프로토콜 활용 예시:

#### 비활성화

```log
[11:56:08] [User Authenticator #0/INFO]: UUID of player mohyomi is 5c803b2d-02d0-4f8e-8f50-965cdfc48714
[11:56:09] [Server thread/INFO]: mohyomi joined the game
[11:56:10] [Server thread/INFO]: mohyomi[/111.111.111.111:62672] logged in with entity id 44 at ([world]0, 0, 0)
```

<p align="center">플래이어  접속시, 표시되는 ip 주소 111.111.111.111는 Wrdefense+의 주소에요.</p>

<p align="center">이 경우 다음과 같은 제한이 있어요.</p>

* 모든 유저가 동일한 IP로 인식됨
* IP 밴, IP 화이트리스트가 정상적으로 작동하지 않음

#### 활성화

```log
[11:56:08] [User Authenticator #0/INFO]: UUID of player mohyomi is 5c803b2d-02d0-4f8e-8f50-965cdfc48714
[11:56:09] [Server thread/INFO]: mohyomi joined the game
[11:56:10] [Server thread/INFO]: mohyomi[/123.123.123.123:68642] logged in with entity id 44 at ([world]0, 0, 0)
```

<p align="center">프록시 프로토콜 사용시, 123.123.123.123은 접속 플래이어의 공개 ip에요.</p>

<p align="center">Wrdefense+ 뒤에 숨겨진 <strong>실제 접속 플레이어의 공개 IP</strong>를 인식할 수 있어요!</p>

<p align="center">이는 다음과 같은 이점이 있어요.</p>

* 접속 로그에 실제 유저 IP 기록
* IP 밴, 국가 차단, 접속 제한 등 IP 기반 기능 정상 작동
* 보안 및 관리 목적의 정확한 유저 식별 가능

## 추가 정보

<figure><img src="https://209055715-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVkJmXC0Zry3o8BxDQbFQ%2Fuploads%2Fbj6VO6npdE86v0LuoLXN%2FG%20..png?alt=media&#x26;token=e9f87f2e-4a3c-40c1-98c1-9562f8ddee39" alt="" width="375"><figcaption></figcaption></figure>

<p align="center">활성화 클릭시, 나타나는 룰렛이에요.</p>

```ts
const segments = 6;
const segmentAngle = (Math.PI * 2) / segments;
```

<p align="center">룰렛은 원형이므로, 모든 위치는 <strong>각도(라디안)</strong> 로 계산해요.</p>

```ts
const successSegments = [1, 3, 5];
const targetSegmentIndex =
    successSegments[Math.floor(Math.random() * successSegments.length)];
```

<p align="center">결과는 회전 전에 이미 결정되고, <code>꽝</code> 세그먼트는 제외하고, <code>성공</code> 세그먼트만 후보로 사용해요.</p>

```ts
const segmentOffset =
    -(targetSegmentIndex * segmentAngle + segmentAngle / 2);
```

<p align="center">선택된 <code>성공</code> 세그먼트의 <strong>중앙이 화살표 아래에 오도록</strong> 목표 각도를 계산해요.</p>

```ts
const fullRotations = 8 + Math.floor(Math.random() * 5);
const totalRotation =
    fullRotations * Math.PI * 2 + segmentOffset;
```

<p align="center">자연스럽게 보이기 위해 여러 바퀴를 먼저 돌려줘요.</p>

```ts
currentRotation =
    slowDownStartRotation +
    (totalRotation - slowDownStartRotation) * easeOutCubic(progress);
```

<p align="center">룰렛이 감속하면서, 현재 회전 각도에서 <code>totalRotation</code>까지 부드럽게 이동해요.</p>

```ts
currentRotation = totalRotation;
```

<p align="center">최종적으로, 룰렛은 꽝 없이 100% 확률로 성공에서 멈춰요!</p>

<p align="center">프록시 프로토콜과 연관성이 없는 기능 및 설명으로, 단순한 시각적으로 매리트가 있는 룰렛이에요.</p>
