Skip to content

Commit

Permalink
initialize commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdikhody committed Jan 6, 2024
0 parents commit b53af10
Show file tree
Hide file tree
Showing 9 changed files with 3,515 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"plugin:prettier/recommended",
"prettier",
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": ["@typescript-eslint"],
"rules": {}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build
node_modules
7 changes: 7 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
src
test

.eslintrc.json
.prettierrc.json
tsconfig.json
8 changes: 8 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"semi": true,
"singleQuote": false,
"trailingComma": "all",
"printWidth": 80,
"tabWidth": 4,
"endOfLine": "auto"
}
83 changes: 83 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# 3x-ui

This is an interface for 3x-ui panel. It will help developers to create, edit and delete inbounds and clients in a simple way.
This package is developed based on [MHSanaei Postman Collection](https://documenter.getpostman.com/view/16802678/2s9YkgD5jm#9cac8101-017e-4415-94e2-d30f4dcf49de) and you can check it out for more information.

## Installation

You can install this package using npm:

```bash
npm install 3x-ui
```

## Usage

First of all, you need to import the package:

```javascript
import { XUI } from "3x-ui";
```

Then you can use the functions:

```javascript
const panel = new XUI("localhost", 2053, "username", "password");

const inbounds = await panel.getInbounds();
const clients = await panel.getClients();
const clientStat = await panel.getClient("email");
const clientOptions = await panel.getClientOptions("email");
const onlines = await panel.getOnlineClients();
```

## Functions

### getInbounds()

This function will return all inbounds in an array.

```javascript
const inbounds = await panel.getInbounds();
```

### getInbound(id: number)

This function will return an inbound with the given id.

```javascript
const inbound = await panel.getInbound(1);
```

### addInbound(options: InboundOptions)

This function will add a new inbound with the given options.

```javascript
const inbound = await panel.addInbound({
enable: true,
remark: "New inbound",
listen: "",
port: 48965,
protocol: "vmess",
expiryTime: 0,
settings: JSON.stringify({
clients: [],
decryption: "none",
fallbacks: [],
}),
streamSettings: JSON.stringify({
network: "ws",
security: "none",
wsSettings: {
acceptProxyProtocol: false,
path: "/",
headers: {},
},
}),
sniffing: JSON.stringify({
enabled: true,
destOverride: ["http", "tls"],
}),
});
```
Loading

0 comments on commit b53af10

Please sign in to comment.