{$layout "layout_popup"}

<h3>修改源站</h3>

<form method="post" class="ui form" data-tea-action="$" data-tea-success="success">
	<input type="hidden" name="reverseProxyId" :value="reverseProxyId"/>
	<input type="hidden" name="originType" :value="originType"/>
	<input type="hidden" name="originId" :value="originId"/>

	<table class="ui table selectable definition">
		<tr>
			<td>源站协议</td>
			<td>
				<!-- HTTP -->
				<select class="ui dropdown auto-width" name="protocol" v-model="origin.protocol" v-if="serverType == 'httpProxy' || serverType == 'httpWeb'" @change="changeProtocol">
					<option value="http">HTTP</option>
					<option value="https">HTTPS</option>
				</select>

				<!-- TCP -->
				<select class="ui dropdown auto-width" name="protocol" v-model="origin.protocol" v-if="serverType == 'tcpProxy'">
					<option value="tcp">TCP</option>
					<option value="tls">TLS</option>
				</select>

                <!-- UDP -->
                <select class="ui dropdown auto-width" name="protocol" v-model="origin.protocol" v-if="serverType == 'udpProxy'">
                    <option value="udp">UDP</option>
                </select>
			</td>
		</tr>
		<tr>
			<td class="title">源站地址</td>
			<td>
				<input type="text" name="addr" ref="focus" v-model="origin.addr" @input="changeAddr"/>
				<p class="comment"><span class="red" v-if="addrError.length > 0">{{addrError}}</span>源站服务器地址，通常是一个IP（或域名）加端口<span v-if="serverType == 'httpProxy'">，不需要加 http:// 或 https://</span>。</p>
			</td>
		</tr>
        <tr v-if="isHTTP">
            <td>专属域名</td>
            <td>
                <domains-box :v-domains="origin.domains"></domains-box>
                <p class="comment">不为空时，指定的这些域名访问时当前源站才生效。</p>
            </td>
        </tr>
		<tr>
			<td colspan="2"><more-options-indicator></more-options-indicator></td>
		</tr>
		<tbody v-show="moreOptionsVisible">
            <tr>
                <td>权重</td>
                <td>
                    <input type="text" name="weight" maxlength="4" v-model="origin.weight"  style="width:5em"/>
                    <p class="comment">数字越大，代表分配的请求比例越多。</p>
                </td>
            </tr>
			<tr>
				<td>名称</td>
				<td>
					<input type="text" name="name" maxlength="100" v-model="origin.name"/>
					<p class="comment">给当前源站起一个容易识别的名称。</p>
				</td>
			</tr>
            <tr>
                <td>连接失败超时时间</td>
                <td>
                    <div class="ui fields inline">
                        <div class="ui field">
                            <input type="text" name="connTimeout" value="10" size="6" v-model="origin.connTimeout"/>
                        </div>
                        <div class="ui field">
                            秒
                        </div>
                    </div>
                    <p class="comment">连接源站失败的最大超时时间，0表示不限制。</p>
                </td>
            </tr>
            <tr v-if="isHTTP">
                <td>读取超时时间</td>
                <td>
                    <div class="ui fields inline">
                        <div class="ui field">
                            <input type="text" name="readTimeout" value="0" size="6" v-model="origin.readTimeout"/>
                        </div>
                        <div class="ui field">
                            秒
                        </div>
                    </div>
                    <p class="comment">读取内容时的最大超时时间，0表示不限制。</p>
                </td>
            </tr>
            <tr v-if="isHTTP">
                <td>最大并发连接数</td>
                <td>
                    <div class="ui fields inline">
                        <div class="ui field">
                            <input type="text" name="maxConns" value="0" size="6" maxlength="10" v-model="origin.maxConns"/>
                        </div>
                    </div>
                    <p class="comment">源站可以接受到的最大并发连接数，0表示使用系统默认。</p>
                </td>
            </tr>
            <tr v-if="isHTTP">
                <td>最大空闲连接数</td>
                <td>
                    <div class="ui fields inline">
                        <div class="ui field">
                            <input type="text" name="maxIdleConns" value="0" size="6" maxlength="10" v-model="origin.maxIdleConns"/>
                        </div>
                    </div>
                    <p class="comment">当没有请求时，源站保持等待的最大空闲连接数量，0表示使用系统默认。</p>
                </td>
            </tr>
            <tr v-if="isHTTP">
                <td>最大空闲超时时间</td>
                <td>
                    <div class="ui fields inline">
                        <div class="ui field">
                            <input type="text" name="idleTimeout" value="0" size="6" v-model="origin.idleTimeout"/>
                        </div>
                        <div class="ui field">
                            秒
                        </div>
                    </div>
                    <p class="comment">源站保持等待的空闲超时时间，0表示使用默认时间。</p>
                </td>
            </tr>
			<tr>
				<td>备注</td>
				<td>
					<textarea name="description" rows="3" maxlength="100" v-model="origin.description"></textarea>
				</td>
			</tr>
			<tr>
				<td>是否启用</td>
				<td>
					<checkbox name="isOn" :value="origin.isOn"></checkbox>
				</td>
			</tr>
		</tbody>
	</table>
	<submit-btn></submit-btn>
</form>