Posted on Leave a comment

About module parser

The module parser is a feature that allows you to convert modules from other apps to LanceX’s format. We list the directives that we support.

sgmodule

General

  • force-http-engine-hosts

Rule

  • DOMAIN
  • DOMAIN-SUFFIX
  • DOMAIN-KEYWORD
  • IP-CIDR
  • IP-CIDR6
  • GEOIP
  • IP-ASN
  • URL-REGEX
  • USER-AGENT
  • AND/OR/NOT
  • FINAL
  • REJECT
  • REJECT-DROP

Rewrite

  • 302
  • reject
  • reject-200
  • reject-img
  • reject-dict
  • reject-array
  • header
  • header-add
  • header-del
  • header-replace
  • header-replace-regex

Body Rewrite

  • http-request
  • http-response

Map Local

Local mapping is supported, but the data file must be remote currently

Script

  • http-request
  • http-response

loon

Rule

  • DOMAIN
  • DOMAIN-SUFFIX
  • DOMAIN-KEYWORD
  • IP-CIDR
  • IP-CIDR6
  • GEOIP
  • IP-ASN
  • URL-REGEX
  • USER-AGENT
  • AND/OR/NOT
  • FINAL

Rewrite

  • 302
  • reject
  • reject-200
  • reject-img
  • reject-dict
  • reject-array
  • header-add
  • header-del
  • header-replace
  • header-replace-regex
  • request-body-replace-regex
  • request-body-json-jq
  • request-body-json-add
  • request-body-json-replace
  • request-body-json-del
  • mock-request-body
  • response-header-add
  • response-header-del
  • response-header-replace
  • response-header-replace-regex
  • response-body-replace-regex
  • response-body-json-add
  • response-body-json-replace
  • response-body-json-del
  • response-body-json-jq
  • mock-response-body

Script

  • http-request
  • http-response

Posted on Leave a comment

About experiment setting

The meanings of them are not important. Please do not switch on any options because they are all untested. If one option proves to be stable enough, it will become the default setting.

Unlimited connections

The memory constraints of network extensions are very stringent. For iOS versions below 15, the limit is 15MB, which increases to 50MB for iOS 15 and later versions. If the VPN exceeds this limit, it will be shut down silently by the system. Therefore, we limit the number of connections. If you switch it on, the protection will be turned off.

Use “Network” framework

The new Network.framework API provides direct access to the same high-performance user-space networking stack used by URLSession. However, in testing, we cannot achieve fine-grained control over its memory usage, making it prone to crashing.

Mux on H2

HTTP/2 has built-in multiplexing, which can reduce resource usage. However, enabling it may decrease transfer speed during testing. We are working on optimizing its performance to make it the default option.

Forbid network dectection

When the network changes, we should gather more information about the current environment, but this action may interrupt the current connections. Turning it on may mitigate the impact, but at the cost of losing some underlying network information.

Use third-party TLS solution

The default network framework in iOS is highly effective but outdated. We will attempt to use it initially. We will not test it when you enable it.

Rough switch network

We will close all previous connections when the network changes if you turn it on.

Add port in WS host

We will use the host of the WebSocket settings when upgrading to the WebSocket protocol. However, if it does not use the default port and you forget to set it in the settings, it may or may not run correctly depending on your server. We will always add the port in the host header if the server does not use the default port, once you enable it.

Posted on Leave a comment

What is “Lock Subscription”

There is an option in the subscription called ‘Lock’.

A locked subscription means that there are certain limitations on modifying and sharing it.

  1. You cannot view or modify the details of a locked subscription, but you can delete it.
  2. You cannot share a locked subscription unless you have the password for the lock.
  3. When sharing a locked subscription, you have two options: either requiring a password to import or allowing anyone to import it.

Please note that locking a subscription is a feature exclusive to LanceX. You cannot share the URL with applications other than LanceX.

Posted on Leave a comment

What’s “Trust DNS”?

There is an option in Rule -> Advance named Trust DNS. That’s allow the proxy to use the IPs from local DNS.

For example, when you want to access a.com, and it does not match any domain directives in the rules, it will be resolved by the local DNS. If the IP result matches an IP directive with the target set to PROXY, it will pass locally resolved IP to the proxy instead of the domain, provided that you have enabled this feature.

Posted on 1 Comment

Proxy Provider

What is a Proxy Provider?

A Proxy Provider is an engine used to determine which proxy is used for the current network flow.

In LanceX, the Proxy Provider chooses a proxy exclusively based on a Regular Expression. This allows for dynamic updates when adding or removing proxies.

Additionally, a Proxy Provider can be embedded within another Proxy Provider, forming a tree map structure.

What are the types of Proxy Provider?

There are four types of Proxy Provider:

  1. select: This type allows manual selection of a proxy. However, please note that it may not be accurate if your proxies change.
  2. fallback: This type selects proxies in a sequential order. If the current proxy is down or times out, the next one in line will be used.
  3. load_balance: This type efficiently distributes incoming network traffic across a group of proxies.
  4. url-test: This type selects the proxy to be used by benchmarking the speed to a specific URL.

How to set Proxy Provider?

There are two ways to set Proxy Provider:

  1. You can set it globally in Rule > Advance > Default Proxy Parameter. All routes matching PROXY will use the Proxy Provider. Please note that if you set this, the proxy you selected in Proxy View will not affect the connection, and the proxy details in the Control Panel will also change based on the Proxy Provider results.
  2. You can also set it for individual rules. When you change a rule’s target to PROXY, you can choose a Proxy Provider.
Posted on Leave a comment

What’s “Prepend Script”?

There is an option in Rule -> Advance named Prepend Script. The script you put in will be triggered together with other scripts each time.

So you can:

  • Add some code to debug.
  • Enhance the script ability.
  • Add some util libraries.
  • Although we support most of the APIs, some of the scripts use global variables to check the App type, so we can pretend as other runtime, for example Rocket(https://shadowboat.app/lancex/module/rocket.js)
Posted on 5 Comments

Where can I buy …?

Where can I buy LanceX?

The only way to purchase it is from the Apple Store.

Where can I buy a server?

Please seek suggestions from people in your country. The situation varies between countries, and the servers suggested or provided by others may not meet your specific requirements. Of course, if possible, building it yourself is always a good option.

Posted on Leave a comment

Scripting

You can use JavaScript to extend the ability of LanceX.

Public API

$done() function

Since all scripts run asynchronously, $done() should be called to indicate completion, even for scripts that do not require results. Otherwise, the script will print a warning due to a timeout.

Basic Information

  • $lancex

The object means that you are in the environment of LanceX.

Persistent Store

  • $persistentStore.write(data<String>, [key<String>])

Save data permanently. Only a string is allowed

  • $persistentStore.read([key<String>])

Get the saved data. Return a string or null.

Http Request

  • $httpClient.post(URL<String> or options<Object>, callback<Function>)

Start an HTTP POST request. The first parameter can be a URL or object. An example object may look like that.

{
    url: "http://www.example.com/",
    headers: {
        "Content-Type": "application/json"
    },
    body: "{}",
    timeout: 5,
    callback: callback(error, response, data) {

    }
}

The url is always required. body can be a string or object. When presenting an object, it is encoded to JSON string, and the Content-Type is set to application/json automatically.

Similar function: $httpClient.get, $httpClient.put$httpClient.delete, $httpClient.head, $httpClient.options, $httpClient.patch.

  • fetch(URL<String>, options<Object>)

It’s an implementation of Fetch API, for example

fetch("http://www.example.com/",{
    method: "POST",
    headers: {
        "Content-Type": "application/json"
    },
    body: "{}"
}).then(v=>v.text())
.then(v=>console.log(v));

Utilities

  • console.log(message<String>)

Log to LanceX logfile. Similar function: console.warn, console.error, console.info.

  • setTimeout(function[, delay])

Same as the setTimeout in browsers. Similar function: setInterval.

  • $notification.post(title<String>, subtitle<String>, body<String>, info<Object>)

Post a notification. Please turn on Allow Notifications before using it. info allows you to open a url when user clicks the notification. For example:

{
   "open-url" : "https://www.example.com"
}