<commit_before>#!/bin/bash

usage() { echo "Usage: $0 -h <v2ray hostname/address> -u <v2ray client uuid> [-p <v2ray port numbert>] [-a <v2ray alterid>] [-v <v2ray level>]" 1>&2; exit 1; }

while getopts ":a:k:l:h:p:s:u:v:" o; do
	case "${o}" in
		a)
			ALTERID="$(echo -e "${OPTARG}" | tr -d '[:space:]')"
			;;
		k)
			SOCKSPORT="$(echo -e "${OPTARG}" | tr -d '[:space:]')"
			;;
		l)
			LSTNADDR="$(echo -e "${OPTARG}" | tr -d '[:space:]')"
			;;
		h)
			VHOST="$(echo -e "${OPTARG}" | tr -d '[:space:]')"
			;;
		p)
			VPORT="$(echo -e "${OPTARG}" | tr -d '[:space:]')"
			;;
		s)
			SECURITY="$(echo -e "${OPTARG}" | tr -d '[:space:]')"
			;;
		u)
			UUID="$(echo -e "${OPTARG}" | tr -d '[:space:]')"
			;;
		v)
			LEVEL="$(echo -e "${OPTARG}" | tr -d '[:space:]')"
			;;
		*)
			usage;
	esac
done
if [ -z "${VHOST}" ] || [ -z "${UUID}" ]; then
	usage
fi

if [ -z "${LSTNADDR}" ]; then
	LSTNADDR="0.0.0.0"
fi

if [ -z "${SOCKSPORT}" ]; then
	SOCKSPORT=1080
fi

if [ -z "${VPORT}" ]; then
	VPORT=10086
fi

if [ -z "${ALTERID}" ]; then
	ALTERID=16
fi

if [ -z "${LEVEL}" ]; then
	LEVEL=0
fi

if [ -z "${LEVEL}" ]; then
	SECURITY="auto"
fi

shift $((OPTIND-1))

cd /tmp
cp -a /usr/bin/v2ray/vpoint_socks_vmess.json vsv.json
jq "(.inbounds[] | select( .protocol == \"socks\") | .listen) |= \"${LSTNADDR}\"" vsv.json >vsv.json.1
jq "(.inbounds[] | select( .protocol == \"socks\") | .port) |= \"${SOCKSPORT}\"" vsv.json.1 >vsv.json.2
jq "(.inbounds[] | select( .protocol == \"socks\") | .settings.ip) |= \"0.0.0.0\"" vsv.json.2>vsv.json.3
jq "(.outbounds[] | select( .protocol == \"freedom\") | .protocol) |= \"vmess\"" vsv.json.3>vsv.json.4
jq ".outbounds[0].settings |= . + { \"vnext\": [{\"address\": \"${VHOST}\", \"port\": ${VPORT}, \"users\": [{\"id\": \"${UUID}\", \"alterId\": ${ALTERID}, \"security\": \"${SECURITY}\", \"level\": ${LEVEL}}]}] }" vsv.json.4>client.json

/usr/bin/nohup /usr/bin/v2ray/v2ray -config=/tmp/client.json &
/root/polipo/polipo -c /root/polipo/config
exec /usr/bin/dnscrypt-proxy -config /etc/dnscrypt-proxy/dnscrypt-proxy.toml
<commit_msg>V2Ray SECURITY setting typo fix<commit_after>#!/bin/bash

usage() { echo "Usage: $0 -h <v2ray hostname/address> -u <v2ray uuid> [-p <v2ray port number>] [-a <v2ray alterid>] [-v <v2ray level>]" 1>&2; exit 1; }

while getopts ":a:k:l:h:p:s:u:v:" o; do
	case "${o}" in
		a)
			ALTERID="$(echo -e "${OPTARG}" | tr -d '[:space:]')"
			;;
		k)
			SOCKSPORT="$(echo -e "${OPTARG}" | tr -d '[:space:]')"
			;;
		l)
			LSTNADDR="$(echo -e "${OPTARG}" | tr -d '[:space:]')"
			;;
		h)
			VHOST="$(echo -e "${OPTARG}" | tr -d '[:space:]')"
			;;
		p)
			VPORT="$(echo -e "${OPTARG}" | tr -d '[:space:]')"
			;;
		s)
			SECURITY="$(echo -e "${OPTARG}" | tr -d '[:space:]')"
			;;
		u)
			UUID="$(echo -e "${OPTARG}" | tr -d '[:space:]')"
			;;
		v)
			LEVEL="$(echo -e "${OPTARG}" | tr -d '[:space:]')"
			;;
		*)
			usage;
	esac
done
if [ -z "${VHOST}" ] || [ -z "${UUID}" ]; then
	usage
fi

if [ -z "${LSTNADDR}" ]; then
	LSTNADDR="0.0.0.0"
fi

if [ -z "${SOCKSPORT}" ]; then
	SOCKSPORT=1080
fi

if [ -z "${VPORT}" ]; then
	VPORT=10086
fi

if [ -z "${ALTERID}" ]; then
	ALTERID=16
fi

if [ -z "${LEVEL}" ]; then
	LEVEL=0
fi

if [ -z "${SECURITY}" ]; then
	SECURITY="auto"
fi

shift $((OPTIND-1))

cd /tmp
cp -a /usr/bin/v2ray/vpoint_socks_vmess.json vsv.json
jq "(.inbounds[] | select( .protocol == \"socks\") | .listen) |= \"${LSTNADDR}\"" vsv.json >vsv.json.1
jq "(.inbounds[] | select( .protocol == \"socks\") | .port) |= \"${SOCKSPORT}\"" vsv.json.1 >vsv.json.2
jq "(.inbounds[] | select( .protocol == \"socks\") | .settings.ip) |= \"0.0.0.0\"" vsv.json.2>vsv.json.3
jq "(.outbounds[] | select( .protocol == \"freedom\") | .protocol) |= \"vmess\"" vsv.json.3>vsv.json.4
jq ".outbounds[0].settings |= . + { \"vnext\": [{\"address\": \"${VHOST}\", \"port\": ${VPORT}, \"users\": [{\"id\": \"${UUID}\", \"alterId\": ${ALTERID}, \"security\": \"${SECURITY}\", \"level\": ${LEVEL}}]}] }" vsv.json.4>client.json

/usr/bin/nohup /usr/bin/v2ray/v2ray -config=/tmp/client.json &
/root/polipo/polipo -c /root/polipo/config
exec /usr/bin/dnscrypt-proxy -config /etc/dnscrypt-proxy/dnscrypt-proxy.toml

{'fraction_non_alphanumeric': 0.29059417849410635, 'fraction_numerical': 0.020447438056290596, 'mean_word_length': 3.141434262948207, 'pattern_counts': {'":': 18, '<': 13, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5749024', 'n_tokens_mistral': 1988, 'n_tokens_neox': 1837, 'n_words': 413}