<template>
  <div class="python_scan_main">
    <el-descriptions title="WAF状态" :model="waf_status">
      <el-descriptions-item label="mod_security是否安装">
        <el-tag type="success" v-if="waf_status.modsecurity_installed">已经安装</el-tag>
        <el-tag type="danger" v-else>未安装</el-tag>
      </el-descriptions-item>
      <el-descriptions-item label="mod_security是否配置">
        <el-tag type="success" v-if="waf_status.modsecurity_config">已经安装</el-tag>
        <el-tag type="danger" v-else>未安装</el-tag>
      </el-descriptions-item>
      <el-descriptions-item label="owasp_crs是否安装">
        <el-tag type="success" v-if="waf_status.owasp_crs">已经安装</el-tag>
        <el-tag type="danger" v-else>未安装</el-tag>
      </el-descriptions-item>
    </el-descriptions>
    <div>
      <el-button type="success" @click="install_waf">安装WAF</el-button>
      <el-button type="info" @click="get_waf_info">刷新WAF状态</el-button>
    </div>
    <el-descriptions title="防火墙" style="margin-top: 10px">
      <el-descriptions-item label="防火墙是否启动">
        <el-tag type="success" v-if="ufw_status">已启动</el-tag>
        <el-tag type="danger" v-else>未启动</el-tag>
      </el-descriptions-item>
    </el-descriptions>
    <div>
      <el-button type="success" @click="open_ufw">启动防火墙</el-button>
      <el-button type="info" @click="get_ufw_status">刷新防火墙状态</el-button>
    </div>
    <el-form :inline="true" :model="ban_form" class="demo-form-inline" style="margin-top: 20px">
      <el-form-item label="IP">
        <el-input v-model="ban_form.ip" placeholder="IP"></el-input>
      </el-form-item>
      <el-form-item label="端口">
        <el-input v-model="ban_form.port" placeholder="IP"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="ban_ip">禁止</el-button>
      </el-form-item>
    </el-form>
    <el-input
        type="textarea"
        style="margin-top: 10px"
        :autosize="{ minRows: 2, maxRows: 100}"
        placeholder="日志分析内容"
        v-model="info_show">
    </el-input>
    <div style="margin-top: 10px">
      <el-button type="info" @click="get_log_analyze">获取日志分析内容</el-button>
    </div>
  </div>
</template>

<script src="./defend.js"></script>

<style src="./defend.css" scoped></style>