<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Gustavo Henrique.net</title>
	<atom:link href="http://www.gustavohenrique.net/brogui/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gustavohenrique.net/brogui</link>
	<description>Programação, Redes e Tecnologia</description>
	<lastBuildDate>Fri, 05 Feb 2010 13:12:53 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Participe do Flex for Kids</title>
		<link>http://www.gustavohenrique.net/brogui/2010/02/participe-do-flex-for-kids/</link>
		<comments>http://www.gustavohenrique.net/brogui/2010/02/participe-do-flex-for-kids/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 13:11:14 +0000</pubDate>
		<dc:creator>gustavohenrique</dc:creator>
				<category><![CDATA[Sem categoria]]></category>
		<category><![CDATA[evento]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://www.gustavohenrique.net/brogui/?p=239</guid>
		<description><![CDATA[
&#8220;O Flex for Kids é uma maratona de palestras on-line que será realizado no dia 06/02/2010 e contará com grandes nomes da comunidade Adobe Flex brasileira.
Serão 10 palestras on-line ao vivo durante o dia inteiro, usando um ambiente de eventos multimídia onde os palestrantes ministrarão seus temas através de recursos de áudio, vídeo, slides e [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.gustavohenrique.net/brogui/wp-content/uploads/2010/02/flexforkids.jpg"><img src="http://www.gustavohenrique.net/brogui/wp-content/uploads/2010/02/flexforkids.jpg" alt="flexforkids" title="flexforkids" width="250" height="82" class="aligncenter size-full wp-image-240" /></a></p>
<p>&#8220;O <a href="http://www.flexforkids.com" target="_blank">Flex for Kids</a> é uma maratona de palestras on-line que será realizado no dia 06/02/2010 e contará com grandes nomes da comunidade Adobe Flex brasileira.<br />
Serão 10 palestras on-line ao vivo durante o dia inteiro, usando um ambiente de eventos multimídia onde os palestrantes ministrarão seus temas através de recursos de áudio, vídeo, slides e chat.<br />
Qualquer pessoa, empresa ou faculdade poderá participar do Flex for Kids, para isto basta fazer uma doação de um valor simbólico de R$ 30,00 para ter acesso as 10 palestras on-line e suas gravações que serão disponibilizadas 15 dias após o evento.<br />
Todo dinheiro arrecadado será doado ao Cotolengo de Mato Grosso do Sul. Para conhecer a Cotolengo <a href="http://www.flexforkids.com/site/favored" target="_blank">clique aqui.</a>&#8221;</p>
<p>Óbviamente eu já me inscrevi! E você?</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Compartilhe esse artigo</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http://www.gustavohenrique.net/brogui/2010/02/participe-do-flex-for-kids/&amp;submitHeadline=Participe+do+Flex+for+Kids&amp;submitSummary=" rel="nofollow" title="Adicionar ao&nbsp;Buzz"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/buzz.png" title="Adicionar ao&nbsp;Buzz" alt="Adicionar ao&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.gustavohenrique.net/brogui/2010/02/participe-do-flex-for-kids/&amp;title=Participe+do+Flex+for+Kids" rel="nofollow" title="Adicionar ao&nbsp;Del.icio.us"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/delicious.png" title="Adicionar ao&nbsp;Del.icio.us" alt="Adicionar ao&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.gustavohenrique.net/brogui/2010/02/participe-do-flex-for-kids/&amp;title=Participe+do+Flex+for+Kids" rel="nofollow" title="Adicionar ao&nbsp;digg"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/digg.png" title="Adicionar ao&nbsp;digg" alt="Adicionar ao&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://www.gustavohenrique.net/brogui/2010/02/participe-do-flex-for-kids/" rel="nofollow" title="Adicionar ao&nbsp;Facebook"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/facebook.png" title="Adicionar ao&nbsp;Facebook" alt="Adicionar ao&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://www.gustavohenrique.net/brogui/2010/02/participe-do-flex-for-kids/&amp;title=Participe+do+Flex+for+Kids" rel="nofollow" title="Adicionar ao&nbsp;Google Bookmarks"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/google.png" title="Adicionar ao&nbsp;Google Bookmarks" alt="Adicionar ao&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http://www.gustavohenrique.net/brogui/2010/02/participe-do-flex-for-kids/&amp;bm_description=Participe+do+Flex+for+Kids" rel="nofollow" title="Adicionar ao&nbsp;Mister Wong"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Adicionar ao&nbsp;Mister Wong" alt="Adicionar ao&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://www.gustavohenrique.net/brogui/2010/02/participe-do-flex-for-kids/&amp;T=Participe+do+Flex+for+Kids" rel="nofollow" title="Adicionar ao&nbsp;Netscape"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/netscape.png" title="Adicionar ao&nbsp;Netscape" alt="Adicionar ao&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://www.gustavohenrique.net/brogui/2010/02/participe-do-flex-for-kids/&amp;title=Participe+do+Flex+for+Kids" rel="nofollow" title="Adicionar ao&nbsp;reddit"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/reddit.png" title="Adicionar ao&nbsp;reddit" alt="Adicionar ao&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.gustavohenrique.net/brogui/2010/02/participe-do-flex-for-kids/&amp;title=Participe+do+Flex+for+Kids" rel="nofollow" title="Adicionar ao&nbsp;Stumble Upon"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Adicionar ao&nbsp;Stumble Upon" alt="Adicionar ao&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://www.gustavohenrique.net/brogui/2010/02/participe-do-flex-for-kids/" rel="nofollow" title="Adicionar ao&nbsp;Technorati"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/technorati.png" title="Adicionar ao&nbsp;Technorati" alt="Adicionar ao&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http://www.gustavohenrique.net/brogui/2010/02/participe-do-flex-for-kids/" rel="nofollow" title="Adicionar ao&nbsp;Tip'd"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/tipd.png" title="Adicionar ao&nbsp;Tip'd" alt="Adicionar ao&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Participe+do+Flex+for+Kids+@+http://www.gustavohenrique.net/brogui/2010/02/participe-do-flex-for-kids/" rel="nofollow" title="Adicionar ao&nbsp;Twitter"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/twitter.png" title="Adicionar ao&nbsp;Twitter" alt="Adicionar ao&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://www.gustavohenrique.net/brogui/2010/02/participe-do-flex-for-kids/&amp;t=Participe+do+Flex+for+Kids" rel="nofollow" title="Adicionar ao&nbsp;Yahoo My Web"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Adicionar ao&nbsp;Yahoo My Web" alt="Adicionar ao&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.gustavohenrique.net/brogui/2010/02/participe-do-flex-for-kids/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Django usando Pisa para converter HTML para PDF</title>
		<link>http://www.gustavohenrique.net/brogui/2010/02/django-usando-pisa-para-converter-html-para-pdf/</link>
		<comments>http://www.gustavohenrique.net/brogui/2010/02/django-usando-pisa-para-converter-html-para-pdf/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 18:02:49 +0000</pubDate>
		<dc:creator>gustavohenrique</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[pisa]]></category>

		<guid isPermaLink="false">http://www.gustavohenrique.net/brogui/?p=235</guid>
		<description><![CDATA[
Pisa é um conversor de HTML/XHTML/CSS para PDF, escrito em Python e baseado nas bibliotecas Reportlab, PyPDF, TechGame Networks CSS e HTML5lib. Seu foco principal não é gerar páginas perfeitas para impressão, mas utilizar HTML e CSS para gerar PDFs dentro de aplicações.
A instalação pode ser feita através do código no site do projeto ou [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.gustavohenrique.net/brogui/wp-content/uploads/2010/02/tower_pisa.jpg"><img src="http://www.gustavohenrique.net/brogui/wp-content/uploads/2010/02/tower_pisa.jpg" alt="Torre de Pisa" title="Torre de Pisa" width="130" height="200" class="aligncenter size-full wp-image-236" /></a></p>
<p>Pisa é um conversor de HTML/XHTML/CSS para PDF, escrito em Python e baseado nas bibliotecas Reportlab, PyPDF, TechGame Networks CSS e HTML5lib. Seu foco principal não é gerar páginas perfeitas para impressão, mas utilizar HTML e CSS para gerar PDFs dentro de aplicações.<br />
A instalação pode ser feita através do código no <a href="http://pypi.python.org/pypi/pisa/" target="_blank">site do projeto</a> ou pelo comando <code>easy_install pisa</code>.</p>
<p>Crie um arquivo chamado <code>report.py</code> dentro do diretório do projeto contendo o código abaixo:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># -*- coding: utf-8 -*-</span>
<span style="color: #ff7700;font-weight:bold;">from</span> django <span style="color: #ff7700;font-weight:bold;">import</span> http
<span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">template</span>.<span style="color: black;">loader</span> <span style="color: #ff7700;font-weight:bold;">import</span> get_template
<span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">template</span> <span style="color: #ff7700;font-weight:bold;">import</span> Context
<span style="color: #ff7700;font-weight:bold;">import</span> ho.<span style="color: black;">pisa</span> <span style="color: #ff7700;font-weight:bold;">as</span> pisa
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">cStringIO</span> <span style="color: #ff7700;font-weight:bold;">as</span> <span style="color: #dc143c;">StringIO</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">cgi</span>, <span style="color: #dc143c;">os</span>
&nbsp;
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> fetch_resources<span style="color: black;">&#40;</span>uri, rel<span style="color: black;">&#41;</span>:
    path = <span style="color: #483d8b;">'/path/para/diretorio/contendo/imagens/a/serem/exibidas'</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> path
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> write_to_pdf<span style="color: black;">&#40;</span>template_src, context_dict, filename<span style="color: black;">&#41;</span>:
    template = get_template<span style="color: black;">&#40;</span>template_src<span style="color: black;">&#41;</span>
    context = Context<span style="color: black;">&#40;</span>context_dict<span style="color: black;">&#41;</span>
    html  = template.<span style="color: black;">render</span><span style="color: black;">&#40;</span>context<span style="color: black;">&#41;</span>
    result = <span style="color: #dc143c;">StringIO</span>.<span style="color: #dc143c;">StringIO</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    pdf = pisa.<span style="color: black;">pisaDocument</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">StringIO</span>.<span style="color: #dc143c;">StringIO</span><span style="color: black;">&#40;</span>html.<span style="color: black;">encode</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;UTF-8&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>, result, link_callback=fetch_resources<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> pdf.<span style="color: black;">err</span>:
        response = http.<span style="color: black;">HttpResponse</span><span style="color: black;">&#40;</span>mimetype=<span style="color: #483d8b;">'application/pdf'</span><span style="color: black;">&#41;</span>
        response<span style="color: black;">&#91;</span><span style="color: #483d8b;">'Content-Disposition'</span><span style="color: black;">&#93;</span> = <span style="color: #483d8b;">'attachment; filename=%s.pdf'</span> <span style="color: #66cc66;">%</span> filename
        response.<span style="color: black;">write</span><span style="color: black;">&#40;</span>result.<span style="color: black;">getvalue</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">return</span> response
    <span style="color: #ff7700;font-weight:bold;">return</span> http.<span style="color: black;">HttpResponse</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'Problema ao gerar PDF: %s'</span> <span style="color: #66cc66;">%</span> <span style="color: #dc143c;">cgi</span>.<span style="color: black;">escape</span><span style="color: black;">&#40;</span>html<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>E agora, dentro de uma <code>view</code>, é preciso importar o arquivo <code>report.py</code> e chamar a função <code>write_to_pdf</code> para fazer a conversão:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># views.py</span>
<span style="color: #ff7700;font-weight:bold;">from</span> report <span style="color: #ff7700;font-weight:bold;">import</span> write_to_pdf
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> listar_clientes_cadastrados<span style="color: black;">&#40;</span>request<span style="color: black;">&#41;</span>:
    clientes = Cliente.<span style="color: black;">objects</span>.<span style="color: #008000;">all</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> write_to_pdf<span style="color: black;">&#40;</span><span style="color: #483d8b;">'relatorio.html'</span>, <span style="color: black;">&#123;</span><span style="color: #483d8b;">'clientes'</span>: clientes<span style="color: black;">&#125;</span>, <span style="color: #483d8b;">'nome_do_arquivo_pdf'</span><span style="color: black;">&#41;</span></pre></div></div>

<p>A função <code>write_to_pdf</code> recebe como parâmetro o nome do arquivo HTML que será convertido, as variáveis que serão tratadas dentro desse arquivo e o nome que o arquivo PDF sem a extensão. Retorna o download do arquivo PDF.</p>
<p>Conforme citado no início do post, a conversão não é perfeita. Por exemplo, às vezes uma tabela apresenta mínimas deformações, não fica igual como na versão HTML. Apesar disso Pisa é uma ótima solução que muitas vezes ajuda bastante e, como puderam ver, é muito fácil de usar.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Compartilhe esse artigo</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http://www.gustavohenrique.net/brogui/2010/02/django-usando-pisa-para-converter-html-para-pdf/&amp;submitHeadline=Django+usando+Pisa+para+converter+HTML+para+PDF&amp;submitSummary=" rel="nofollow" title="Adicionar ao&nbsp;Buzz"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/buzz.png" title="Adicionar ao&nbsp;Buzz" alt="Adicionar ao&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.gustavohenrique.net/brogui/2010/02/django-usando-pisa-para-converter-html-para-pdf/&amp;title=Django+usando+Pisa+para+converter+HTML+para+PDF" rel="nofollow" title="Adicionar ao&nbsp;Del.icio.us"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/delicious.png" title="Adicionar ao&nbsp;Del.icio.us" alt="Adicionar ao&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.gustavohenrique.net/brogui/2010/02/django-usando-pisa-para-converter-html-para-pdf/&amp;title=Django+usando+Pisa+para+converter+HTML+para+PDF" rel="nofollow" title="Adicionar ao&nbsp;digg"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/digg.png" title="Adicionar ao&nbsp;digg" alt="Adicionar ao&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://www.gustavohenrique.net/brogui/2010/02/django-usando-pisa-para-converter-html-para-pdf/" rel="nofollow" title="Adicionar ao&nbsp;Facebook"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/facebook.png" title="Adicionar ao&nbsp;Facebook" alt="Adicionar ao&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://www.gustavohenrique.net/brogui/2010/02/django-usando-pisa-para-converter-html-para-pdf/&amp;title=Django+usando+Pisa+para+converter+HTML+para+PDF" rel="nofollow" title="Adicionar ao&nbsp;Google Bookmarks"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/google.png" title="Adicionar ao&nbsp;Google Bookmarks" alt="Adicionar ao&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http://www.gustavohenrique.net/brogui/2010/02/django-usando-pisa-para-converter-html-para-pdf/&amp;bm_description=Django+usando+Pisa+para+converter+HTML+para+PDF" rel="nofollow" title="Adicionar ao&nbsp;Mister Wong"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Adicionar ao&nbsp;Mister Wong" alt="Adicionar ao&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://www.gustavohenrique.net/brogui/2010/02/django-usando-pisa-para-converter-html-para-pdf/&amp;T=Django+usando+Pisa+para+converter+HTML+para+PDF" rel="nofollow" title="Adicionar ao&nbsp;Netscape"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/netscape.png" title="Adicionar ao&nbsp;Netscape" alt="Adicionar ao&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://www.gustavohenrique.net/brogui/2010/02/django-usando-pisa-para-converter-html-para-pdf/&amp;title=Django+usando+Pisa+para+converter+HTML+para+PDF" rel="nofollow" title="Adicionar ao&nbsp;reddit"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/reddit.png" title="Adicionar ao&nbsp;reddit" alt="Adicionar ao&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.gustavohenrique.net/brogui/2010/02/django-usando-pisa-para-converter-html-para-pdf/&amp;title=Django+usando+Pisa+para+converter+HTML+para+PDF" rel="nofollow" title="Adicionar ao&nbsp;Stumble Upon"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Adicionar ao&nbsp;Stumble Upon" alt="Adicionar ao&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://www.gustavohenrique.net/brogui/2010/02/django-usando-pisa-para-converter-html-para-pdf/" rel="nofollow" title="Adicionar ao&nbsp;Technorati"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/technorati.png" title="Adicionar ao&nbsp;Technorati" alt="Adicionar ao&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http://www.gustavohenrique.net/brogui/2010/02/django-usando-pisa-para-converter-html-para-pdf/" rel="nofollow" title="Adicionar ao&nbsp;Tip'd"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/tipd.png" title="Adicionar ao&nbsp;Tip'd" alt="Adicionar ao&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Django+usando+Pisa+para+converter+HTML+para+PDF+@+http://www.gustavohenrique.net/brogui/2010/02/django-usando-pisa-para-converter-html-para-pdf/" rel="nofollow" title="Adicionar ao&nbsp;Twitter"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/twitter.png" title="Adicionar ao&nbsp;Twitter" alt="Adicionar ao&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://www.gustavohenrique.net/brogui/2010/02/django-usando-pisa-para-converter-html-para-pdf/&amp;t=Django+usando+Pisa+para+converter+HTML+para+PDF" rel="nofollow" title="Adicionar ao&nbsp;Yahoo My Web"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Adicionar ao&nbsp;Yahoo My Web" alt="Adicionar ao&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.gustavohenrique.net/brogui/2010/02/django-usando-pisa-para-converter-html-para-pdf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Acessando BD Firebird através do KinterbasDB no Python</title>
		<link>http://www.gustavohenrique.net/brogui/2010/01/acessando-firebird-atraves-do-kinterbasdb-no-python/</link>
		<comments>http://www.gustavohenrique.net/brogui/2010/01/acessando-firebird-atraves-do-kinterbasdb-no-python/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 15:00:12 +0000</pubDate>
		<dc:creator>gustavohenrique</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[firebird]]></category>

		<guid isPermaLink="false">http://www.gustavohenrique.net/brogui/?p=226</guid>
		<description><![CDATA[
KinterbasDB é uma biblioteca open source para Python que possibilita acessar banco de dados Firebird e algumas versões do Interbase.
O download pode ser feito na página do projeto.
Após o download, descompacte o pacote kinterbasdb-3.2.src.tar.gz.
Abra um terminal, entre no diretório onde o kinterbasdb foi descompactado e execute o comando python setup.py build. O script de instalação, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.gustavohenrique.net/brogui/wp-content/uploads/2010/01/firebird-icon.gif"><img src="http://www.gustavohenrique.net/brogui/wp-content/uploads/2010/01/firebird-icon.gif" alt="firebird-icon" title="firebird-icon" width="66" height="67" class="aligncenter size-full wp-image-229" /></a></p>
<p>KinterbasDB é uma biblioteca open source para Python que possibilita acessar banco de dados Firebird e algumas versões do Interbase.<br />
O download pode ser feito na <a href="http://kinterbasdb.sourceforge.net/" target="_blank">página do projeto</a>.</p>
<p>Após o download, descompacte o pacote <code>kinterbasdb-3.2.src.tar.gz</code>.<br />
Abra um terminal, entre no diretório onde o kinterbasdb foi descompactado e execute o comando <code>python setup.py build</code>. O script de instalação, setup.py, automaticamente vai detectar as informações necessárias pelo compilador C.<br />
Se não ocorreu nenhum erro, execute o comando <code>python setup.py install</code> para instalar no diretório padrão de módulos do Python (varia de acordo com a distro).</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">root@localhost: ~# wget http://downloads.sourceforge.net/project/kinterbasdb/kinterbasdb/kinterbasdb-3.2/kinterbasdb-3.2.src.tar.gz?use_mirror=ufpr
root@localhost: ~# tar zxvf kinterbasdb-3.2.src.tar.gz
root@localhost: ~# python setup.py build
Succeeded:
  /usr/bin/python setup.py build
root@localhost: ~# python setup.py install</pre></div></div>

<p>Para testar se foi instalado corretamente:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">root@localhost: ~# python -c &quot;import kinterbasdb as k; print k.__version__&quot;
(3, 2, 0, 'final', 0)
root@localhost: ~#</pre></div></div>

<p>É possível que apareça uma mensagem de erro em distros baseadas no Ubuntu:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">Traceback (most recent call last):
  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
kinterbasdb.OperationalError: (-901, 'begin transaction: \n  invalid parameter in transaction parameter block')</pre></div></div>

<p>Para corrigir esse problema é preciso usar uma outra versão do arquivo <code>__init__.py</code>.<br />
Faça o download em <a href="https://firebird.svn.sourceforge.net/svnroot/firebird/qa/trunk/kinterbasdb/__init__.py" target="_blank">https://firebird.svn.sourceforge.net/svnroot/firebird/qa/trunk/kinterbasdb/__init__.py</a> e substitua o arquivo existente no diretório <code>kinterbasdb</code>.</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">root@localhost: ~# wget https://firebird.svn.sourceforge.net/svnroot/firebird/qa/trunk/kinterbasdb/__init__.py
root@localhost: ~# mv __init__.py /usr/lib/python2.5/site-packages/kinterbasdb/</pre></div></div>

<p>Exemplo para Firebird-2.1 em servidor Windows:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> kinterbasdb
conn = kinterbasdb.<span style="color: black;">connect</span><span style="color: black;">&#40;</span>
    host=<span style="color: #483d8b;">'192.168.0.2'</span>,
    database=<span style="color: #483d8b;">'C:<span style="color: #000099; font-weight: bold;">\\</span>Dados<span style="color: #000099; font-weight: bold;">\\</span>meubanco.fdb'</span>,
    <span style="color: #dc143c;">user</span>=<span style="color: #483d8b;">'sysdba'</span>,
    password=<span style="color: #483d8b;">'masterkey'</span>
<span style="color: black;">&#41;</span>
cur = conn.<span style="color: black;">cursor</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
cur.<span style="color: black;">execute</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'SELECT id, nome, telefone FROM tabela'</span><span style="color: black;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;">for</span> <span style="color: black;">&#40;</span><span style="color: #008000;">id</span>, nome, telefone<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">in</span> cur:
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'ID: %s, Nome: %s, Fone: %s'</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span><span style="color: #008000;">id</span>, nome, telefone<span style="color: black;">&#41;</span></pre></div></div>

<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Compartilhe esse artigo</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http://www.gustavohenrique.net/brogui/2010/01/acessando-firebird-atraves-do-kinterbasdb-no-python/&amp;submitHeadline=Acessando+BD+Firebird+atrav%C3%A9s+do+KinterbasDB+no+Python&amp;submitSummary=" rel="nofollow" title="Adicionar ao&nbsp;Buzz"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/buzz.png" title="Adicionar ao&nbsp;Buzz" alt="Adicionar ao&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.gustavohenrique.net/brogui/2010/01/acessando-firebird-atraves-do-kinterbasdb-no-python/&amp;title=Acessando+BD+Firebird+atrav%C3%A9s+do+KinterbasDB+no+Python" rel="nofollow" title="Adicionar ao&nbsp;Del.icio.us"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/delicious.png" title="Adicionar ao&nbsp;Del.icio.us" alt="Adicionar ao&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.gustavohenrique.net/brogui/2010/01/acessando-firebird-atraves-do-kinterbasdb-no-python/&amp;title=Acessando+BD+Firebird+atrav%C3%A9s+do+KinterbasDB+no+Python" rel="nofollow" title="Adicionar ao&nbsp;digg"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/digg.png" title="Adicionar ao&nbsp;digg" alt="Adicionar ao&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://www.gustavohenrique.net/brogui/2010/01/acessando-firebird-atraves-do-kinterbasdb-no-python/" rel="nofollow" title="Adicionar ao&nbsp;Facebook"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/facebook.png" title="Adicionar ao&nbsp;Facebook" alt="Adicionar ao&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://www.gustavohenrique.net/brogui/2010/01/acessando-firebird-atraves-do-kinterbasdb-no-python/&amp;title=Acessando+BD+Firebird+atrav%C3%A9s+do+KinterbasDB+no+Python" rel="nofollow" title="Adicionar ao&nbsp;Google Bookmarks"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/google.png" title="Adicionar ao&nbsp;Google Bookmarks" alt="Adicionar ao&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http://www.gustavohenrique.net/brogui/2010/01/acessando-firebird-atraves-do-kinterbasdb-no-python/&amp;bm_description=Acessando+BD+Firebird+atrav%C3%A9s+do+KinterbasDB+no+Python" rel="nofollow" title="Adicionar ao&nbsp;Mister Wong"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Adicionar ao&nbsp;Mister Wong" alt="Adicionar ao&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://www.gustavohenrique.net/brogui/2010/01/acessando-firebird-atraves-do-kinterbasdb-no-python/&amp;T=Acessando+BD+Firebird+atrav%C3%A9s+do+KinterbasDB+no+Python" rel="nofollow" title="Adicionar ao&nbsp;Netscape"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/netscape.png" title="Adicionar ao&nbsp;Netscape" alt="Adicionar ao&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://www.gustavohenrique.net/brogui/2010/01/acessando-firebird-atraves-do-kinterbasdb-no-python/&amp;title=Acessando+BD+Firebird+atrav%C3%A9s+do+KinterbasDB+no+Python" rel="nofollow" title="Adicionar ao&nbsp;reddit"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/reddit.png" title="Adicionar ao&nbsp;reddit" alt="Adicionar ao&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.gustavohenrique.net/brogui/2010/01/acessando-firebird-atraves-do-kinterbasdb-no-python/&amp;title=Acessando+BD+Firebird+atrav%C3%A9s+do+KinterbasDB+no+Python" rel="nofollow" title="Adicionar ao&nbsp;Stumble Upon"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Adicionar ao&nbsp;Stumble Upon" alt="Adicionar ao&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://www.gustavohenrique.net/brogui/2010/01/acessando-firebird-atraves-do-kinterbasdb-no-python/" rel="nofollow" title="Adicionar ao&nbsp;Technorati"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/technorati.png" title="Adicionar ao&nbsp;Technorati" alt="Adicionar ao&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http://www.gustavohenrique.net/brogui/2010/01/acessando-firebird-atraves-do-kinterbasdb-no-python/" rel="nofollow" title="Adicionar ao&nbsp;Tip'd"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/tipd.png" title="Adicionar ao&nbsp;Tip'd" alt="Adicionar ao&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Acessando+BD+Firebird+atrav%C3%A9s+do+KinterbasDB+no+Python+@+http://www.gustavohenrique.net/brogui/2010/01/acessando-firebird-atraves-do-kinterbasdb-no-python/" rel="nofollow" title="Adicionar ao&nbsp;Twitter"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/twitter.png" title="Adicionar ao&nbsp;Twitter" alt="Adicionar ao&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://www.gustavohenrique.net/brogui/2010/01/acessando-firebird-atraves-do-kinterbasdb-no-python/&amp;t=Acessando+BD+Firebird+atrav%C3%A9s+do+KinterbasDB+no+Python" rel="nofollow" title="Adicionar ao&nbsp;Yahoo My Web"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Adicionar ao&nbsp;Yahoo My Web" alt="Adicionar ao&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.gustavohenrique.net/brogui/2010/01/acessando-firebird-atraves-do-kinterbasdb-no-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Formulários dinâmicos no Django</title>
		<link>http://www.gustavohenrique.net/brogui/2010/01/formularios-dinamicos-no-django/</link>
		<comments>http://www.gustavohenrique.net/brogui/2010/01/formularios-dinamicos-no-django/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 18:23:47 +0000</pubDate>
		<dc:creator>gustavohenrique</dc:creator>
				<category><![CDATA[Django]]></category>

		<guid isPermaLink="false">http://www.gustavohenrique.net/brogui/?p=221</guid>
		<description><![CDATA[
Um formulário dinâmico é aquele que o usuário pode definir quais campos vão existir. O programador não precisa criar código para cada formulário.
Imagine um sistema que necessite de diversos tipos de formulários. Tarefa no mínimo entediante para o responsável pela manutenção. E se o usuário puder criar e modificar um formulário por uma interface gráfica [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.gustavohenrique.net/brogui/wp-content/uploads/2010/01/FormFill.jpg"><img src="http://www.gustavohenrique.net/brogui/wp-content/uploads/2010/01/FormFill.jpg" alt="FormFill" title="FormFill" width="250" height="166" class="aligncenter size-full wp-image-222" /></a></p>
<p>Um formulário dinâmico é aquele que o usuário pode definir quais campos vão existir. O programador não precisa criar código para cada formulário.<br />
Imagine um sistema que necessite de diversos tipos de formulários. Tarefa no mínimo entediante para o responsável pela manutenção. E se o usuário puder criar e modificar um formulário por uma interface gráfica fácil de usar? Seria muito bom para o programador!<br />
O segredo desse dinamismo é o uso de metaclasses, que são classes cujas instâncias também são classes.<br />
O truque é criar em tempo de execução uma metaclasse da classe <code>forms.Form</code>. Atributos dos campos como label, tipo, max length etc, podem ficar armazenados no banco de dados. Os valores dos campos podem ficar em outra tabela com uma referência de chave estrangeira. Usando o ORM do Django é muito simples, e de quebra já ganha uma interface gráfica para administrar tudo (admin).<br />
Sendo assim, o usuário poderia montar os campos do formulário definindo um label, tipo de campo, se é obrigatório ou não, valor padrão&#8230; e essas informações ficarão no armazenadas no BD. Fica fácil criar um código para pegar essas informações, criar uma nova classe <code>Form</code> em tempo de execução, instância-la e renderizar no template.</p>
<p>Exemplo:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># views.py</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">views</span>.<span style="color: black;">generic</span>.<span style="color: black;">simple</span> <span style="color: #ff7700;font-weight:bold;">import</span> direct_to_template
<span style="color: #ff7700;font-weight:bold;">from</span> django.<span style="color: black;">forms</span> <span style="color: #ff7700;font-weight:bold;">import</span> forms, fields
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> montar_formulario_dinamico<span style="color: black;">&#40;</span>request<span style="color: black;">&#41;</span>:
    campos_dinamicos = <span style="color: black;">&#123;</span>
        <span style="color: #483d8b;">'nome'</span>: fields.<span style="color: black;">CharField</span><span style="color: black;">&#40;</span>max_length=<span style="color: #ff4500;">100</span>, required=<span style="color: #008000;">True</span>, label=<span style="color: #483d8b;">'Nome'</span>, initial=<span style="color: #483d8b;">'Gustavo'</span><span style="color: black;">&#41;</span>,
        <span style="color: #483d8b;">'idade'</span>: fields.<span style="color: black;">IntegerField</span><span style="color: black;">&#40;</span>label=<span style="color: #483d8b;">'Idade'</span>, min_value=<span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span>,
        <span style="color: #483d8b;">'email'</span>: fields.<span style="color: black;">EmailField</span><span style="color: black;">&#40;</span>max_length=<span style="color: #ff4500;">200</span>, required=<span style="color: #008000;">False</span>, label=<span style="color: #483d8b;">'E-mail'</span><span style="color: black;">&#41;</span>
    <span style="color: black;">&#125;</span>
&nbsp;
    FormDinamico = <span style="color: #008000;">type</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">''</span>, <span style="color: black;">&#40;</span>forms.<span style="color: black;">Form</span>,<span style="color: black;">&#41;</span>, campos_dinamicos<span style="color: black;">&#41;</span>
    form = FormDinamico<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">return</span> direct_to_template<span style="color: black;">&#40;</span>request, <span style="color: #483d8b;">'formulario.html'</span>, extra_context=<span style="color: black;">&#123;</span><span style="color: #483d8b;">'formulario'</span>: form<span style="color: black;">&#125;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>Fica a dica!</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Compartilhe esse artigo</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http://www.gustavohenrique.net/brogui/2010/01/formularios-dinamicos-no-django/&amp;submitHeadline=Formul%C3%A1rios+din%C3%A2micos+no+Django&amp;submitSummary=" rel="nofollow" title="Adicionar ao&nbsp;Buzz"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/buzz.png" title="Adicionar ao&nbsp;Buzz" alt="Adicionar ao&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.gustavohenrique.net/brogui/2010/01/formularios-dinamicos-no-django/&amp;title=Formul%C3%A1rios+din%C3%A2micos+no+Django" rel="nofollow" title="Adicionar ao&nbsp;Del.icio.us"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/delicious.png" title="Adicionar ao&nbsp;Del.icio.us" alt="Adicionar ao&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.gustavohenrique.net/brogui/2010/01/formularios-dinamicos-no-django/&amp;title=Formul%C3%A1rios+din%C3%A2micos+no+Django" rel="nofollow" title="Adicionar ao&nbsp;digg"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/digg.png" title="Adicionar ao&nbsp;digg" alt="Adicionar ao&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://www.gustavohenrique.net/brogui/2010/01/formularios-dinamicos-no-django/" rel="nofollow" title="Adicionar ao&nbsp;Facebook"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/facebook.png" title="Adicionar ao&nbsp;Facebook" alt="Adicionar ao&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://www.gustavohenrique.net/brogui/2010/01/formularios-dinamicos-no-django/&amp;title=Formul%C3%A1rios+din%C3%A2micos+no+Django" rel="nofollow" title="Adicionar ao&nbsp;Google Bookmarks"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/google.png" title="Adicionar ao&nbsp;Google Bookmarks" alt="Adicionar ao&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http://www.gustavohenrique.net/brogui/2010/01/formularios-dinamicos-no-django/&amp;bm_description=Formul%C3%A1rios+din%C3%A2micos+no+Django" rel="nofollow" title="Adicionar ao&nbsp;Mister Wong"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Adicionar ao&nbsp;Mister Wong" alt="Adicionar ao&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://www.gustavohenrique.net/brogui/2010/01/formularios-dinamicos-no-django/&amp;T=Formul%C3%A1rios+din%C3%A2micos+no+Django" rel="nofollow" title="Adicionar ao&nbsp;Netscape"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/netscape.png" title="Adicionar ao&nbsp;Netscape" alt="Adicionar ao&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://www.gustavohenrique.net/brogui/2010/01/formularios-dinamicos-no-django/&amp;title=Formul%C3%A1rios+din%C3%A2micos+no+Django" rel="nofollow" title="Adicionar ao&nbsp;reddit"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/reddit.png" title="Adicionar ao&nbsp;reddit" alt="Adicionar ao&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.gustavohenrique.net/brogui/2010/01/formularios-dinamicos-no-django/&amp;title=Formul%C3%A1rios+din%C3%A2micos+no+Django" rel="nofollow" title="Adicionar ao&nbsp;Stumble Upon"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Adicionar ao&nbsp;Stumble Upon" alt="Adicionar ao&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://www.gustavohenrique.net/brogui/2010/01/formularios-dinamicos-no-django/" rel="nofollow" title="Adicionar ao&nbsp;Technorati"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/technorati.png" title="Adicionar ao&nbsp;Technorati" alt="Adicionar ao&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http://www.gustavohenrique.net/brogui/2010/01/formularios-dinamicos-no-django/" rel="nofollow" title="Adicionar ao&nbsp;Tip'd"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/tipd.png" title="Adicionar ao&nbsp;Tip'd" alt="Adicionar ao&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Formul%C3%A1rios+din%C3%A2micos+no+Django+@+http://www.gustavohenrique.net/brogui/2010/01/formularios-dinamicos-no-django/" rel="nofollow" title="Adicionar ao&nbsp;Twitter"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/twitter.png" title="Adicionar ao&nbsp;Twitter" alt="Adicionar ao&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://www.gustavohenrique.net/brogui/2010/01/formularios-dinamicos-no-django/&amp;t=Formul%C3%A1rios+din%C3%A2micos+no+Django" rel="nofollow" title="Adicionar ao&nbsp;Yahoo My Web"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Adicionar ao&nbsp;Yahoo My Web" alt="Adicionar ao&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.gustavohenrique.net/brogui/2010/01/formularios-dinamicos-no-django/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Servidor Linux com Proxy e Controle de Banda – Parte 3</title>
		<link>http://www.gustavohenrique.net/brogui/2010/01/servidor-linux-com-proxy-e-controle-de-banda-%e2%80%93-parte-3/</link>
		<comments>http://www.gustavohenrique.net/brogui/2010/01/servidor-linux-com-proxy-e-controle-de-banda-%e2%80%93-parte-3/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 19:00:10 +0000</pubDate>
		<dc:creator>gustavohenrique</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[qos]]></category>
		<category><![CDATA[shell script]]></category>

		<guid isPermaLink="false">http://www.gustavohenrique.net/brogui/?p=210</guid>
		<description><![CDATA[
Finalmente consegui escrever a última parte do artigo. 
Nas partes 1 e 2 mostrei como configurar um servidor Linux para firewall e controle de banda, usando scripts que fazem a leitura de um arquivo texto contendo as informações dos pontos de rede (IP, MAC, velocidade de download e upload&#8230;). Entretanto, acessar o servidor e ficar [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.gustavohenrique.net/brogui/wp-content/uploads/2010/01/firewall.jpg"><img src="http://www.gustavohenrique.net/brogui/wp-content/uploads/2010/01/firewall.jpg" alt="firewall" title="firewall" width="300" height="240" class="aligncenter size-full wp-image-219" /></a><br />
Finalmente consegui escrever a última parte do artigo. <img src='http://www.gustavohenrique.net/brogui/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /><br />
Nas partes 1 e 2 mostrei como configurar um servidor Linux para firewall e controle de banda, usando scripts que fazem a leitura de um arquivo texto contendo as informações dos pontos de rede (IP, MAC, velocidade de download e upload&#8230;). Entretanto, acessar o servidor e ficar editando um arquivo texto, na minha opinião é muito chato, possui risco de falha humana e apenas quem tem acesso ao servidor pode fazer isso. Para resolver esse contratempo foi desenvolvido o <a href="http://github.com/gustavohenrique/bandcontrol/" target="_blank">Bandcontrol</a>, um pequeno sistema web que armazena os dados dos pontos de rede em um banco de dados e gera o arquivo texto usado pelos shell scripts.<br />
O sistema foi desenvolvido em <a href="http://www.djangobrasil.org" target="_blank">Django</a>, personalizando o <a href="" target="_blank">Admin</a>. Vou mostrar apenas como instalar e usar. O código fonte está disponível para consulta de programadores, curiosos e simpatizantes.<br />
<span id="more-210"></span></p>
<h2>Instalação</h2>
<p>Há diversas maneiras de se instalar um sistema feito em django. Vou mostrar como fazer o deploy usando Apache2 com o módulo mod_wsgi.<br />
O ambiente completo usa Apache2, sqlite3, python-2.6 e Django-1.1.</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">root@localhost# apt-get install apache2 libapache2-mod-wsgi sqlite3 python-pysqlite2 python-django</pre></div></div>

<p>O diretório web padrão do Apache no Ubuntu é o <code>/var/www</code>. Vamos manter assim. Faça o download do <a href="">Bandcontrol</a> pelo site <a href="http://github.com/gustavohenrique/bandcontrol" targer="_blank">github.com</a> (no site, clique no botão Download Source), descompacte no <code>/var/www</code>, renomeie o diretório para <code>bandcontrol</code> e altere o dono/grupo de acordo com o usuário do apache.</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">root@localhost: /var/www# tar zxvf gustavohenrique-bandcontrol-XXXXXX.tar.gz
root@localhost: /var/www# mv gustavohenrique-bandcontrol-XXXXXX bandcontrol
root@localhost: /var/www# chown www-data.www-data -Rf bandcontrol</pre></div></div>

<p>Os shell scripts usam o <code>Iptables</code> para firewall e <code>TC</code> para controle de banda. É necessário permissão de super usuário para executar esses comandos. Vamos configurar o <code>sudo</code> para que o usuário do Apache possa executar tais comandos como root.</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">root@localhost: /var/www# chmod +w /etc/sudoers
root@localhost: /var/www# vim /etc/sudoers</pre></div></div>

<p>Adicione essas linhas no arquivo <code>/etc/sudoers</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;"># No Ubuntu o iptables e o tc estao dentro do /sbin
Cmd_Alias BANDCONTROL = /sbin/iptables, /sbin/tc
www-data  ALL = (ALL) NOPASSWD: BANDCONTROL</pre></div></div>

<h3>Configuracao do Apache</h3>
<p>Configure um virtualhost no apache criando o arquivo <code>/etc/apache2/sites-enabled/bandcontrol</code> contendo:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">WSGIRestrictStdout Off
NameVirtualHost bandcontrol
&lt;VirtualHost bandcontrol&gt;
        ServerAdmin webmaster@localhost
        LimitInternalRecursion 1000
        ServerName bandcontrol
&nbsp;
        &lt;Directory /var/www/bandcontrol&gt;
                Options ExecCGI FollowSymLinks MultiViews
                AllowOverride FileInfo
                MultiviewsMatch Handlers
                Order deny,allow
                Allow from all
        &lt;/Directory&gt;
&nbsp;
        ErrorLog /var/log/apache2/bandcontrol_error.log
        CustomLog /var/log/apache2/bandcontrol_access.log combined
&nbsp;
        WSGIScriptAlias /     &quot;/var/www/bandcontrol/config.wsgi&quot;
&nbsp;
        Alias /admin_media/ &quot;/usr/lib/pymodules/python2.6/django/contrib/admin/media/&quot;
        Alias /media/           &quot;/var/www/bandcontrol/media/&quot;
&lt;/VirtualHost&gt;</pre></div></div>

<p>Edite o <code>/etc/hosts</code> e adicione:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">127.0.0.2     bandcontrol</pre></div></div>

<h3>Configuracao do Bandcontrol</h3>
<p>Altere o arquivo <code>/var/www/bandcontrol/config.wsgi</code> ajustando o diretório de instalação do Django. O padrão do Ubuntu é <code>/usr/lib/pymodules/python2.6/django</code>. Nesse arquivo também é configurado o diretório do bandcontrol:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">os</span>, <span style="color: #dc143c;">sys</span>
PROJECT_ROOT_PATH = <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">dirname</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">abspath</span><span style="color: black;">&#40;</span>__file__<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
<span style="color: #dc143c;">sys</span>.<span style="color: black;">path</span>.<span style="color: black;">insert</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span>, PROJECT_ROOT_PATH<span style="color: black;">&#41;</span>
<span style="color: #dc143c;">sys</span>.<span style="color: black;">path</span>.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'/usr/lib/pymodules/python2.6/django/'</span><span style="color: black;">&#41;</span>
<span style="color: #dc143c;">sys</span>.<span style="color: black;">path</span>.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'/var/www'</span><span style="color: black;">&#41;</span>
<span style="color: #dc143c;">os</span>.<span style="color: black;">environ</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">'DJANGO_SETTINGS_MODULE'</span><span style="color: black;">&#93;</span>=<span style="color: #483d8b;">'settings'</span>
<span style="color: #ff7700;font-weight:bold;">import</span> django.<span style="color: black;">core</span>.<span style="color: black;">handlers</span>.<span style="color: black;">wsgi</span>
application = django.<span style="color: black;">core</span>.<span style="color: black;">handlers</span>.<span style="color: black;">wsgi</span>.<span style="color: black;">WSGIHandler</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">import</span> bandcontrol.<span style="color: black;">monitor</span>
bandcontrol.<span style="color: black;">monitor</span>.<span style="color: black;">start</span><span style="color: black;">&#40;</span>interval=<span style="color: #ff4500;">1.0</span><span style="color: black;">&#41;</span></pre></div></div>

<p>No arquivo <code>/var/www/bandcontrol/settings.py</code> é possível fazer mais alterações.<br />
Para definir as interfaces de rede e classe IP utilizada na rede, edite os arquivos <code>/var/www/bandcontrol/scripts/CONFIG</code> e <code>/var/www/bandcontrol/scripts/firewall</code>.</p>
<p><!-- Cada vez que alterar algum arquivo <code>.py</code> do <code>bandcontrol</code> será necessário atualizar o arquivo <code>config.wsgi</code> para que as alterações surtam efeito. Para isso usamos o comando <code>touch config.wsgi</code>. Outras alternativas são reiniciar o Apache ou utilizar um arquivo <code>monitor.py</code> descrito em artigo anterior nesse mesmo blog. --><br />
Por padrão é utilizado o banco de dados sqlite3. Você pode escolher usar o MySQL ou PostgreSQL editando o arquivo <code>/var/www/bandcontrol/settings.py</code>.<br />
Para criar o BD, entre no diretório do bandcontrol e execute o comando <code>manage.py syncdb</code>. Digite <code>yes</code> para confirmar a criação do super usuário. Forneça um login, e-mail e senha:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">root@localhost: /var/www/bandcontrol# python manage.py syncdb
Creating table auth_permission
Creating table auth_group
Creating table auth_user
Creating table auth_message
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table django_admin_log
Creating table rede_plano
Creating table rede_pontorede
&nbsp;
You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (Leave blank to use 'root'): gustavo
E-mail address: eu@gustavohenrique.net
Password:
Password (again):
Superuser created successfully.
Installing index for auth.Permission model
Installing index for auth.Message model
Installing index for admin.LogEntry model
Installing index for rede.PontoRede model</pre></div></div>

<p>Reinicie o Apache para que as alterações tenham efeito.</p>
<h2>Utilização</h2>
<p>Abra o browser e acesse <b>http://bandcontrol/</b>.<br />
Reparem que no campo de endereço da URL e os nomes de usuário utilizados não condizem com o que foi exemplificado nesse artigo. Bom... estou com preguiça para alterar as imagens, então vamos desconsiderar esse "bug".</p>
<p>Entre com o login e senha criados no passo anterior.<br />
<a href="http://www.gustavohenrique.net/brogui/wp-content/uploads/2010/01/bandcontrol_tela0.jpg"><img src="http://www.gustavohenrique.net/brogui/wp-content/uploads/2010/01/bandcontrol_tela0-300x217.jpg" alt="bandcontrol_tela0" title="bandcontrol_tela0" width="300" height="217" class="aligncenter size-medium wp-image-211" /></a></p>
<p>Tela inicial do sistema.<br />
<a href="http://www.gustavohenrique.net/brogui/wp-content/uploads/2010/01/bandcontrol_tela1.jpg"><img src="http://www.gustavohenrique.net/brogui/wp-content/uploads/2010/01/bandcontrol_tela1-300x217.jpg" alt="bandcontrol_tela1" title="bandcontrol_tela1" width="300" height="217" class="aligncenter size-medium wp-image-212" /></a></p>
<p>Clique em Planos e vamos criar alguns.<br />
<a href="http://www.gustavohenrique.net/brogui/wp-content/uploads/2010/01/bandcontrol_tela2.jpg"><img src="http://www.gustavohenrique.net/brogui/wp-content/uploads/2010/01/bandcontrol_tela2-300x217.jpg" alt="bandcontrol_tela2" title="bandcontrol_tela2" width="300" height="217" class="aligncenter size-medium wp-image-213" /></a></p>
<p>Volte à tela inicial, clique em Pontos de Rede. No menu superior há opção para executar o firewall, parar o controle de banda e exibir os IPs conectados ao servidor. Sempre que fizer alguma alteração no sistema deve executar o firewall para ativar as mudanças.<br />
<a href="http://www.gustavohenrique.net/brogui/wp-content/uploads/2010/01/bandcontrol_tela3.jpg"><img src="http://www.gustavohenrique.net/brogui/wp-content/uploads/2010/01/bandcontrol_tela3-300x217.jpg" alt="bandcontrol_tela3" title="bandcontrol_tela3" width="300" height="217" class="aligncenter size-medium wp-image-214" /></a></p>
<p>Em exibir IPs conectados, para adicionar um IP no sistema forneça uma descrição única, escolha o plano e clique em [+].<br />
<a href="http://www.gustavohenrique.net/brogui/wp-content/uploads/2010/01/bandcontrol_tela4.jpg"><img src="http://www.gustavohenrique.net/brogui/wp-content/uploads/2010/01/bandcontrol_tela4-300x217.jpg" alt="bandcontrol_tela4" title="bandcontrol_tela4" width="300" height="217" class="aligncenter size-medium wp-image-215" /></a></p>
<p>O bandcontrol permite criar outros usuários com acesso ao sistema. Trabalha com permissões e grupos. Cortesia do Django \o/<br />
<a href="http://www.gustavohenrique.net/brogui/wp-content/uploads/2010/01/bandcontrol_tela5.jpg"><img src="http://www.gustavohenrique.net/brogui/wp-content/uploads/2010/01/bandcontrol_tela5-300x217.jpg" alt="bandcontrol_tela5" title="bandcontrol_tela5" width="300" height="217" class="aligncenter size-medium wp-image-216" /></a></p>
<h2>Conclusão</h2>
<p>Bandcontrol foi uma daquelas coisas "pra ontem". Foi feito em uma tarde de terça-feira. Tal velocidade se deve ao framework Django.<br />
Esse artigo foi escrito um pouco de cada vez, por isso há grandes chances de algo sair errado. Há muito material disponível na web sobre deploy de projetos em Django. Em caso de dúvidas estarei disposto a ajudar.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Compartilhe esse artigo</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http://www.gustavohenrique.net/brogui/2010/01/servidor-linux-com-proxy-e-controle-de-banda-%e2%80%93-parte-3/&amp;submitHeadline=Servidor+Linux+com+Proxy+e+Controle+de+Banda+%E2%80%93+Parte+3&amp;submitSummary=" rel="nofollow" title="Adicionar ao&nbsp;Buzz"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/buzz.png" title="Adicionar ao&nbsp;Buzz" alt="Adicionar ao&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.gustavohenrique.net/brogui/2010/01/servidor-linux-com-proxy-e-controle-de-banda-%e2%80%93-parte-3/&amp;title=Servidor+Linux+com+Proxy+e+Controle+de+Banda+%E2%80%93+Parte+3" rel="nofollow" title="Adicionar ao&nbsp;Del.icio.us"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/delicious.png" title="Adicionar ao&nbsp;Del.icio.us" alt="Adicionar ao&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.gustavohenrique.net/brogui/2010/01/servidor-linux-com-proxy-e-controle-de-banda-%e2%80%93-parte-3/&amp;title=Servidor+Linux+com+Proxy+e+Controle+de+Banda+%E2%80%93+Parte+3" rel="nofollow" title="Adicionar ao&nbsp;digg"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/digg.png" title="Adicionar ao&nbsp;digg" alt="Adicionar ao&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://www.gustavohenrique.net/brogui/2010/01/servidor-linux-com-proxy-e-controle-de-banda-%e2%80%93-parte-3/" rel="nofollow" title="Adicionar ao&nbsp;Facebook"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/facebook.png" title="Adicionar ao&nbsp;Facebook" alt="Adicionar ao&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://www.gustavohenrique.net/brogui/2010/01/servidor-linux-com-proxy-e-controle-de-banda-%e2%80%93-parte-3/&amp;title=Servidor+Linux+com+Proxy+e+Controle+de+Banda+%E2%80%93+Parte+3" rel="nofollow" title="Adicionar ao&nbsp;Google Bookmarks"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/google.png" title="Adicionar ao&nbsp;Google Bookmarks" alt="Adicionar ao&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http://www.gustavohenrique.net/brogui/2010/01/servidor-linux-com-proxy-e-controle-de-banda-%e2%80%93-parte-3/&amp;bm_description=Servidor+Linux+com+Proxy+e+Controle+de+Banda+%E2%80%93+Parte+3" rel="nofollow" title="Adicionar ao&nbsp;Mister Wong"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Adicionar ao&nbsp;Mister Wong" alt="Adicionar ao&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://www.gustavohenrique.net/brogui/2010/01/servidor-linux-com-proxy-e-controle-de-banda-%e2%80%93-parte-3/&amp;T=Servidor+Linux+com+Proxy+e+Controle+de+Banda+%E2%80%93+Parte+3" rel="nofollow" title="Adicionar ao&nbsp;Netscape"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/netscape.png" title="Adicionar ao&nbsp;Netscape" alt="Adicionar ao&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://www.gustavohenrique.net/brogui/2010/01/servidor-linux-com-proxy-e-controle-de-banda-%e2%80%93-parte-3/&amp;title=Servidor+Linux+com+Proxy+e+Controle+de+Banda+%E2%80%93+Parte+3" rel="nofollow" title="Adicionar ao&nbsp;reddit"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/reddit.png" title="Adicionar ao&nbsp;reddit" alt="Adicionar ao&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.gustavohenrique.net/brogui/2010/01/servidor-linux-com-proxy-e-controle-de-banda-%e2%80%93-parte-3/&amp;title=Servidor+Linux+com+Proxy+e+Controle+de+Banda+%E2%80%93+Parte+3" rel="nofollow" title="Adicionar ao&nbsp;Stumble Upon"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Adicionar ao&nbsp;Stumble Upon" alt="Adicionar ao&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://www.gustavohenrique.net/brogui/2010/01/servidor-linux-com-proxy-e-controle-de-banda-%e2%80%93-parte-3/" rel="nofollow" title="Adicionar ao&nbsp;Technorati"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/technorati.png" title="Adicionar ao&nbsp;Technorati" alt="Adicionar ao&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http://www.gustavohenrique.net/brogui/2010/01/servidor-linux-com-proxy-e-controle-de-banda-%e2%80%93-parte-3/" rel="nofollow" title="Adicionar ao&nbsp;Tip'd"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/tipd.png" title="Adicionar ao&nbsp;Tip'd" alt="Adicionar ao&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Servidor+Linux+com+Proxy+e+Controle+de+Banda+%E2%80%93+Parte+3+@+http://www.gustavohenrique.net/brogui/2010/01/servidor-linux-com-proxy-e-controle-de-banda-%e2%80%93-parte-3/" rel="nofollow" title="Adicionar ao&nbsp;Twitter"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/twitter.png" title="Adicionar ao&nbsp;Twitter" alt="Adicionar ao&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://www.gustavohenrique.net/brogui/2010/01/servidor-linux-com-proxy-e-controle-de-banda-%e2%80%93-parte-3/&amp;t=Servidor+Linux+com+Proxy+e+Controle+de+Banda+%E2%80%93+Parte+3" rel="nofollow" title="Adicionar ao&nbsp;Yahoo My Web"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Adicionar ao&nbsp;Yahoo My Web" alt="Adicionar ao&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.gustavohenrique.net/brogui/2010/01/servidor-linux-com-proxy-e-controle-de-banda-%e2%80%93-parte-3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Sprint no Feriado do dia 20/01/2010</title>
		<link>http://www.gustavohenrique.net/brogui/2010/01/sprint-no-feriado-20012010/</link>
		<comments>http://www.gustavohenrique.net/brogui/2010/01/sprint-no-feriado-20012010/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 16:53:46 +0000</pubDate>
		<dc:creator>gustavohenrique</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Sem categoria]]></category>

		<guid isPermaLink="false">http://www.gustavohenrique.net/brogui/?p=207</guid>
		<description><![CDATA[
Essa é uma grande oportunidade para aqueles que não estão acostumados a utilizar metodologias ágeis em projetos reais. Será desenvolvido algo concreto, um pouco mais aprimorado do que os tradicionais exercícios de lógica matemática aplicados no dojo.
É uma chance única para praticar TDD, Scrum e XP, aprender mais sobre Python, Django, Javascript e desenvolvimento web [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.gustavohenrique.net/brogui/wp-content/uploads/2010/01/dojo-rio-logo1.jpg"><img src="http://www.gustavohenrique.net/brogui/wp-content/uploads/2010/01/dojo-rio-logo1.jpg" alt="dojo-rio-logo1" title="dojo-rio-logo1" width="220" height="103" class="aligncenter size-full wp-image-208" /></a><br />
Essa é uma grande oportunidade para aqueles que não estão acostumados a utilizar metodologias ágeis em projetos reais. Será desenvolvido algo concreto, um pouco mais aprimorado do que os tradicionais exercícios de lógica matemática aplicados no dojo.<br />
É uma chance única para praticar TDD, Scrum e XP, aprender mais sobre Python, Django, Javascript e desenvolvimento web em geral, participar de um projeto open source e trocar idéias com outros profissionais da área.<br />
Maiores informações na lista do Coding Dojo Rio:</p>
<p>* Coding Dojo Rio *<br />
dojo-rio@googlegroups.com<br />
http://groups.google.com/group/dojo-rio<br />
http://code.google.com/p/dojo-rio<br />
http://dojorio.wordpress.com</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Compartilhe esse artigo</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http://www.gustavohenrique.net/brogui/2010/01/sprint-no-feriado-20012010/&amp;submitHeadline=Sprint+no+Feriado+do+dia+20%2F01%2F2010&amp;submitSummary=" rel="nofollow" title="Adicionar ao&nbsp;Buzz"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/buzz.png" title="Adicionar ao&nbsp;Buzz" alt="Adicionar ao&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.gustavohenrique.net/brogui/2010/01/sprint-no-feriado-20012010/&amp;title=Sprint+no+Feriado+do+dia+20%2F01%2F2010" rel="nofollow" title="Adicionar ao&nbsp;Del.icio.us"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/delicious.png" title="Adicionar ao&nbsp;Del.icio.us" alt="Adicionar ao&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.gustavohenrique.net/brogui/2010/01/sprint-no-feriado-20012010/&amp;title=Sprint+no+Feriado+do+dia+20%2F01%2F2010" rel="nofollow" title="Adicionar ao&nbsp;digg"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/digg.png" title="Adicionar ao&nbsp;digg" alt="Adicionar ao&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://www.gustavohenrique.net/brogui/2010/01/sprint-no-feriado-20012010/" rel="nofollow" title="Adicionar ao&nbsp;Facebook"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/facebook.png" title="Adicionar ao&nbsp;Facebook" alt="Adicionar ao&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://www.gustavohenrique.net/brogui/2010/01/sprint-no-feriado-20012010/&amp;title=Sprint+no+Feriado+do+dia+20%2F01%2F2010" rel="nofollow" title="Adicionar ao&nbsp;Google Bookmarks"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/google.png" title="Adicionar ao&nbsp;Google Bookmarks" alt="Adicionar ao&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http://www.gustavohenrique.net/brogui/2010/01/sprint-no-feriado-20012010/&amp;bm_description=Sprint+no+Feriado+do+dia+20%2F01%2F2010" rel="nofollow" title="Adicionar ao&nbsp;Mister Wong"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Adicionar ao&nbsp;Mister Wong" alt="Adicionar ao&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://www.gustavohenrique.net/brogui/2010/01/sprint-no-feriado-20012010/&amp;T=Sprint+no+Feriado+do+dia+20%2F01%2F2010" rel="nofollow" title="Adicionar ao&nbsp;Netscape"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/netscape.png" title="Adicionar ao&nbsp;Netscape" alt="Adicionar ao&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://www.gustavohenrique.net/brogui/2010/01/sprint-no-feriado-20012010/&amp;title=Sprint+no+Feriado+do+dia+20%2F01%2F2010" rel="nofollow" title="Adicionar ao&nbsp;reddit"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/reddit.png" title="Adicionar ao&nbsp;reddit" alt="Adicionar ao&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.gustavohenrique.net/brogui/2010/01/sprint-no-feriado-20012010/&amp;title=Sprint+no+Feriado+do+dia+20%2F01%2F2010" rel="nofollow" title="Adicionar ao&nbsp;Stumble Upon"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Adicionar ao&nbsp;Stumble Upon" alt="Adicionar ao&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://www.gustavohenrique.net/brogui/2010/01/sprint-no-feriado-20012010/" rel="nofollow" title="Adicionar ao&nbsp;Technorati"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/technorati.png" title="Adicionar ao&nbsp;Technorati" alt="Adicionar ao&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http://www.gustavohenrique.net/brogui/2010/01/sprint-no-feriado-20012010/" rel="nofollow" title="Adicionar ao&nbsp;Tip'd"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/tipd.png" title="Adicionar ao&nbsp;Tip'd" alt="Adicionar ao&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Sprint+no+Feriado+do+dia+20%2F01%2F2010+@+http://www.gustavohenrique.net/brogui/2010/01/sprint-no-feriado-20012010/" rel="nofollow" title="Adicionar ao&nbsp;Twitter"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/twitter.png" title="Adicionar ao&nbsp;Twitter" alt="Adicionar ao&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://www.gustavohenrique.net/brogui/2010/01/sprint-no-feriado-20012010/&amp;t=Sprint+no+Feriado+do+dia+20%2F01%2F2010" rel="nofollow" title="Adicionar ao&nbsp;Yahoo My Web"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Adicionar ao&nbsp;Yahoo My Web" alt="Adicionar ao&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.gustavohenrique.net/brogui/2010/01/sprint-no-feriado-20012010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bug executando o Eclipse Galileo no Ubuntu 9.10 Karmic Koala</title>
		<link>http://www.gustavohenrique.net/brogui/2010/01/bug-eclipse-galileo-ubuntu-karmic-koala/</link>
		<comments>http://www.gustavohenrique.net/brogui/2010/01/bug-eclipse-galileo-ubuntu-karmic-koala/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 23:36:33 +0000</pubDate>
		<dc:creator>gustavohenrique</dc:creator>
				<category><![CDATA[Dicas]]></category>

		<guid isPermaLink="false">http://www.gustavohenrique.net/brogui/?p=197</guid>
		<description><![CDATA[
Existe um bug no Eclipse Galileo baixado diretamente do eclipse.org que faz com que alguns botões não funcionem. Você clica no botão e nenhum evento é acionado.
Isso acontece porque a GTK 2.18 introduziu uma nova maneira para interagir com GdkWindows. No próximo release da GTK esse problema deve ser corrigido, mas enquanto isso uma solução [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.gustavohenrique.net/brogui/wp-content/uploads/2010/01/eclipse-logo.jpg"><img src="http://www.gustavohenrique.net/brogui/wp-content/uploads/2010/01/eclipse-logo.jpg" alt="eclipse-logo" title="eclipse-logo" width="309" height="180" class="aligncenter size-full wp-image-198" /></a><br />
Existe um bug no Eclipse Galileo baixado diretamente do <a href="www.eclipse.org">eclipse.org</a> que faz com que alguns botões não funcionem. Você clica no botão e nenhum evento é acionado.<br />
Isso acontece porque a GTK 2.18 introduziu uma nova maneira para interagir com GdkWindows. No próximo release da GTK esse problema deve ser corrigido, mas enquanto isso uma solução rápida é usar <code>export GDK_NATIVE_WINDOWS=true</code>.<br />
A versão instalada pelo apt-get vem com o script <code>/usr/bin/eclipse</code> que executa o comando acima antes de chamar o binário do Eclipse.<br />
Fica aí mais uma dica!</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Compartilhe esse artigo</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http://www.gustavohenrique.net/brogui/2010/01/bug-eclipse-galileo-ubuntu-karmic-koala/&amp;submitHeadline=Bug+executando+o+Eclipse+Galileo+no+Ubuntu+9.10+Karmic+Koala&amp;submitSummary=" rel="nofollow" title="Adicionar ao&nbsp;Buzz"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/buzz.png" title="Adicionar ao&nbsp;Buzz" alt="Adicionar ao&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.gustavohenrique.net/brogui/2010/01/bug-eclipse-galileo-ubuntu-karmic-koala/&amp;title=Bug+executando+o+Eclipse+Galileo+no+Ubuntu+9.10+Karmic+Koala" rel="nofollow" title="Adicionar ao&nbsp;Del.icio.us"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/delicious.png" title="Adicionar ao&nbsp;Del.icio.us" alt="Adicionar ao&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.gustavohenrique.net/brogui/2010/01/bug-eclipse-galileo-ubuntu-karmic-koala/&amp;title=Bug+executando+o+Eclipse+Galileo+no+Ubuntu+9.10+Karmic+Koala" rel="nofollow" title="Adicionar ao&nbsp;digg"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/digg.png" title="Adicionar ao&nbsp;digg" alt="Adicionar ao&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://www.gustavohenrique.net/brogui/2010/01/bug-eclipse-galileo-ubuntu-karmic-koala/" rel="nofollow" title="Adicionar ao&nbsp;Facebook"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/facebook.png" title="Adicionar ao&nbsp;Facebook" alt="Adicionar ao&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://www.gustavohenrique.net/brogui/2010/01/bug-eclipse-galileo-ubuntu-karmic-koala/&amp;title=Bug+executando+o+Eclipse+Galileo+no+Ubuntu+9.10+Karmic+Koala" rel="nofollow" title="Adicionar ao&nbsp;Google Bookmarks"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/google.png" title="Adicionar ao&nbsp;Google Bookmarks" alt="Adicionar ao&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http://www.gustavohenrique.net/brogui/2010/01/bug-eclipse-galileo-ubuntu-karmic-koala/&amp;bm_description=Bug+executando+o+Eclipse+Galileo+no+Ubuntu+9.10+Karmic+Koala" rel="nofollow" title="Adicionar ao&nbsp;Mister Wong"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Adicionar ao&nbsp;Mister Wong" alt="Adicionar ao&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://www.gustavohenrique.net/brogui/2010/01/bug-eclipse-galileo-ubuntu-karmic-koala/&amp;T=Bug+executando+o+Eclipse+Galileo+no+Ubuntu+9.10+Karmic+Koala" rel="nofollow" title="Adicionar ao&nbsp;Netscape"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/netscape.png" title="Adicionar ao&nbsp;Netscape" alt="Adicionar ao&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://www.gustavohenrique.net/brogui/2010/01/bug-eclipse-galileo-ubuntu-karmic-koala/&amp;title=Bug+executando+o+Eclipse+Galileo+no+Ubuntu+9.10+Karmic+Koala" rel="nofollow" title="Adicionar ao&nbsp;reddit"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/reddit.png" title="Adicionar ao&nbsp;reddit" alt="Adicionar ao&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.gustavohenrique.net/brogui/2010/01/bug-eclipse-galileo-ubuntu-karmic-koala/&amp;title=Bug+executando+o+Eclipse+Galileo+no+Ubuntu+9.10+Karmic+Koala" rel="nofollow" title="Adicionar ao&nbsp;Stumble Upon"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Adicionar ao&nbsp;Stumble Upon" alt="Adicionar ao&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://www.gustavohenrique.net/brogui/2010/01/bug-eclipse-galileo-ubuntu-karmic-koala/" rel="nofollow" title="Adicionar ao&nbsp;Technorati"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/technorati.png" title="Adicionar ao&nbsp;Technorati" alt="Adicionar ao&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http://www.gustavohenrique.net/brogui/2010/01/bug-eclipse-galileo-ubuntu-karmic-koala/" rel="nofollow" title="Adicionar ao&nbsp;Tip'd"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/tipd.png" title="Adicionar ao&nbsp;Tip'd" alt="Adicionar ao&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Bug+executando+o+Eclipse+Galileo+no+Ubuntu+9.10+Karmic+Koala+@+http://www.gustavohenrique.net/brogui/2010/01/bug-eclipse-galileo-ubuntu-karmic-koala/" rel="nofollow" title="Adicionar ao&nbsp;Twitter"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/twitter.png" title="Adicionar ao&nbsp;Twitter" alt="Adicionar ao&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://www.gustavohenrique.net/brogui/2010/01/bug-eclipse-galileo-ubuntu-karmic-koala/&amp;t=Bug+executando+o+Eclipse+Galileo+no+Ubuntu+9.10+Karmic+Koala" rel="nofollow" title="Adicionar ao&nbsp;Yahoo My Web"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Adicionar ao&nbsp;Yahoo My Web" alt="Adicionar ao&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.gustavohenrique.net/brogui/2010/01/bug-eclipse-galileo-ubuntu-karmic-koala/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dicas Rapidas</title>
		<link>http://www.gustavohenrique.net/brogui/2010/01/dicas-rapidas/</link>
		<comments>http://www.gustavohenrique.net/brogui/2010/01/dicas-rapidas/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 16:26:07 +0000</pubDate>
		<dc:creator>gustavohenrique</dc:creator>
				<category><![CDATA[Dicas]]></category>
		<category><![CDATA[oo]]></category>

		<guid isPermaLink="false">http://www.gustavohenrique.net/brogui/?p=190</guid>
		<description><![CDATA[
Estou tendo um inicio de ano bem agitado e por isso nao escrevo o quanto eu queria.
Sendo assim, para nao deixar tudo as moscas novamente, vou postar umas dicas rapidas e urls legais que valem a pena dar uma olhada.
Antes de mais nada, desculpem qualquer erro de gramatica ou ortografica. Estou com pressa e logado [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.gustavohenrique.net/brogui/wp-content/uploads/2010/01/tips.jpg"><img src="http://www.gustavohenrique.net/brogui/wp-content/uploads/2010/01/tips.jpg" alt="tips" title="tips" width="300" height="303" class="aligncenter size-full wp-image-202" /></a><br />
Estou tendo um inicio de ano bem agitado e por isso nao escrevo o quanto eu queria.<br />
Sendo assim, para nao deixar tudo as moscas novamente, vou postar umas dicas rapidas e urls legais que valem a pena dar uma olhada.<br />
Antes de mais nada, desculpem qualquer erro de gramatica ou ortografica. Estou com pressa e logado sem permissao para alterar o layout do teclado para inserir acentos.</p>
<ul>
<li><a href="http://www.home.unix-ag.org/simon/woof.html" target="_blank"><b>Woof</b></a><br />
Um programa escrito em Python que permite compartilhar um arquivo pela rede de forma rapida e pratica.<br />
<a href="http://www.home.unix-ag.org/simon/woof.html" target="_blank">http://www.home.unix-ag.org/simon/woof.html</a></p>
</li>
<li><a href="http://pedromtavares.wordpress.com/2010/01/06/book-review-the-passionate-programmer/" target="_blank"><b>Resenha do Livro Passionate Programmer </b></a><br />O livro aborda varios aspectos comportamentais que qualquer programador deveria seguir para conseguir sucesso na carreira.<br />
<a href="http://pedromtavares.wordpress.com/2010/01/06/book-review-the-passionate-programmer/" target="_blank">http://pedromtavares.wordpress.com</a></p>
</li>
<li><b>Principios de Orientacao a Objetos</b><br />Leitura obrigatoria para qualquer desenvolvedor:<br /><a href="http://www.dsc.ufcg.edu.br/~jacques/cursos/map/html/pat/herancavscomposicao.htm" target="_blank"><br />
Design Pattern básico: Herança versus Composição</a><br />
<a href="http://www.dsc.ufcg.edu.br/~jacques/cursos/map/html/pat/poli.htm" target="_blank"> Design Pattern básico: Interfaces e Polimorfismo</a><br />
<a href="http://www.dsc.ufcg.edu.br/~jacques/cursos/map/html/pat/expert.htm" target="_blank">Padrões para atribuir responsabilidades: Expert</a><br />
<a href="http://www.dsc.ufcg.edu.br/~jacques/cursos/map/html/pat/creator.htm" target="_blank">Padrões para atribuir responsabilidades: Creator</a><br />
<a href="http://www.dsc.ufcg.edu.br/~jacques/cursos/map/html/pat/lowcoupling.htm" target="_blank">Padrões para atribuir responsabilidades: Baixo Acoplamento</a><br />
<a href="http://www.dsc.ufcg.edu.br/~jacques/cursos/map/html/pat/altacoesao.htm" target="_blank">Padrões para atribuir responsabilidades: Alta Coesão</a><br />
<a href="http://www.codingefficiency.com/2009/07/20/solid-o-open-closed-principle/" target="_blank">SOLID &#8211; O: Open Closed Principle | Coding Efficiency</a><br />
<a href="http://www.codingefficiency.com/2009/07/23/solid-i-interface-segregation-principle/" target="_blank">SOLID &#8211; I: Interface Segregation Principle | Coding Efficiency</a><br />
<a href="http://www.codingefficiency.com/2009/07/27/solid-d-dependency-inversion-principle/" target="_blank">SOLID &#8211; D: Dependency Inversion Principle | Coding Efficiency</a>
  </li>
</ul>
<p>Agora tenho que ir!<br />
Enjoy!</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Compartilhe esse artigo</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http://www.gustavohenrique.net/brogui/2010/01/dicas-rapidas/&amp;submitHeadline=Dicas+Rapidas&amp;submitSummary=" rel="nofollow" title="Adicionar ao&nbsp;Buzz"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/buzz.png" title="Adicionar ao&nbsp;Buzz" alt="Adicionar ao&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.gustavohenrique.net/brogui/2010/01/dicas-rapidas/&amp;title=Dicas+Rapidas" rel="nofollow" title="Adicionar ao&nbsp;Del.icio.us"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/delicious.png" title="Adicionar ao&nbsp;Del.icio.us" alt="Adicionar ao&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.gustavohenrique.net/brogui/2010/01/dicas-rapidas/&amp;title=Dicas+Rapidas" rel="nofollow" title="Adicionar ao&nbsp;digg"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/digg.png" title="Adicionar ao&nbsp;digg" alt="Adicionar ao&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://www.gustavohenrique.net/brogui/2010/01/dicas-rapidas/" rel="nofollow" title="Adicionar ao&nbsp;Facebook"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/facebook.png" title="Adicionar ao&nbsp;Facebook" alt="Adicionar ao&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://www.gustavohenrique.net/brogui/2010/01/dicas-rapidas/&amp;title=Dicas+Rapidas" rel="nofollow" title="Adicionar ao&nbsp;Google Bookmarks"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/google.png" title="Adicionar ao&nbsp;Google Bookmarks" alt="Adicionar ao&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http://www.gustavohenrique.net/brogui/2010/01/dicas-rapidas/&amp;bm_description=Dicas+Rapidas" rel="nofollow" title="Adicionar ao&nbsp;Mister Wong"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Adicionar ao&nbsp;Mister Wong" alt="Adicionar ao&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://www.gustavohenrique.net/brogui/2010/01/dicas-rapidas/&amp;T=Dicas+Rapidas" rel="nofollow" title="Adicionar ao&nbsp;Netscape"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/netscape.png" title="Adicionar ao&nbsp;Netscape" alt="Adicionar ao&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://www.gustavohenrique.net/brogui/2010/01/dicas-rapidas/&amp;title=Dicas+Rapidas" rel="nofollow" title="Adicionar ao&nbsp;reddit"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/reddit.png" title="Adicionar ao&nbsp;reddit" alt="Adicionar ao&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.gustavohenrique.net/brogui/2010/01/dicas-rapidas/&amp;title=Dicas+Rapidas" rel="nofollow" title="Adicionar ao&nbsp;Stumble Upon"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Adicionar ao&nbsp;Stumble Upon" alt="Adicionar ao&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://www.gustavohenrique.net/brogui/2010/01/dicas-rapidas/" rel="nofollow" title="Adicionar ao&nbsp;Technorati"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/technorati.png" title="Adicionar ao&nbsp;Technorati" alt="Adicionar ao&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http://www.gustavohenrique.net/brogui/2010/01/dicas-rapidas/" rel="nofollow" title="Adicionar ao&nbsp;Tip'd"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/tipd.png" title="Adicionar ao&nbsp;Tip'd" alt="Adicionar ao&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Dicas+Rapidas+@+http://www.gustavohenrique.net/brogui/2010/01/dicas-rapidas/" rel="nofollow" title="Adicionar ao&nbsp;Twitter"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/twitter.png" title="Adicionar ao&nbsp;Twitter" alt="Adicionar ao&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://www.gustavohenrique.net/brogui/2010/01/dicas-rapidas/&amp;t=Dicas+Rapidas" rel="nofollow" title="Adicionar ao&nbsp;Yahoo My Web"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Adicionar ao&nbsp;Yahoo My Web" alt="Adicionar ao&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.gustavohenrique.net/brogui/2010/01/dicas-rapidas/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Servidor Linux com Proxy e Controle de Banda &#8211; Parte 2</title>
		<link>http://www.gustavohenrique.net/brogui/2009/12/servidor-linux-com-proxy-e-controle-de-banda-parte-2/</link>
		<comments>http://www.gustavohenrique.net/brogui/2009/12/servidor-linux-com-proxy-e-controle-de-banda-parte-2/#comments</comments>
		<pubDate>Mon, 28 Dec 2009 09:00:45 +0000</pubDate>
		<dc:creator>gustavohenrique</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[proxy]]></category>

		<guid isPermaLink="false">http://www.gustavohenrique.net/brogui/?p=183</guid>
		<description><![CDATA[
Introdução
Nessa segunda parte do artigo vou mostrar como criar um shell script usando o iptables para filtragem de pacotes e CBQ para controle de banda.
O script está fácil de entender e sua utilização é bem simples. É necessário criar um arquivo texto contento informações sobre cada máquina cliente que possui acesso à internet. Informações como [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.gustavohenrique.net/brogui/wp-content/uploads/2009/12/linux_matrix.jpg"><img src="http://www.gustavohenrique.net/brogui/wp-content/uploads/2009/12/linux_matrix.jpg" alt="Linux" title="Linux" width="300" height="225" class="aligncenter size-full wp-image-187" /></a></p>
<h2>Introdução</h2>
<p>Nessa segunda parte do artigo vou mostrar como criar um shell script usando o iptables para filtragem de pacotes e CBQ para controle de banda.<br />
O script está fácil de entender e sua utilização é bem simples. É necessário criar um arquivo texto contento informações sobre cada máquina cliente que possui acesso à internet. Informações como IP, MAC, Download, Upload, se vai passar pelo Squid e se está bloqueado o acesso. Com base nestas informações, o script cria as regras no firewall bloqueando ou liberando acessos, amarrando IP ao endereço MAC, faz proxy transparente e determina qual a velocidade de download e upload para cada um. Fora isso, é criado o arquivo <i>/etc/dhcpd.con</i> usado pelo servidor DHCP associando o IP ao seu MAC, fazendo com que um cliente obtenha sempre o mesmo IP.<br />
<span id="more-183"></span></p>
<h2>Firewall e Controle de Banda</h2>
<p>É recomendado um conhecimento básico sobre Linux e Shell Script para bom entendimento do código.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #007800;">ARQUIVO</span>=<span style="color: #ff0000;">&quot;/var/www/bandcontrol/scripts/pontosderede.txt&quot;</span>     <span style="color: #666666; font-style: italic;"># Contem os pontos de rede cadastrados</span>
&nbsp;
<span style="color: #007800;">MOD</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">which</span> modprobe<span style="color: #7a0874; font-weight: bold;">&#41;</span>                        <span style="color: #666666; font-style: italic;"># Comando para carregar modulos do kernel</span>
<span style="color: #007800;">IPT</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">which</span> iptables<span style="color: #7a0874; font-weight: bold;">&#41;</span>                        <span style="color: #666666; font-style: italic;"># Caminho do iptables</span>
<span style="color: #007800;">TC</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">which</span> tc<span style="color: #7a0874; font-weight: bold;">&#41;</span>                               <span style="color: #666666; font-style: italic;"># tc (pacote iproute2)</span>
&nbsp;
<span style="color: #007800;">I_WAN</span>=<span style="color: #ff0000;">&quot;eth0&quot;</span>                                 <span style="color: #666666; font-style: italic;"># Interface internet</span>
<span style="color: #007800;">I_LAN1</span>=<span style="color: #ff0000;">&quot;eth1&quot;</span>                                <span style="color: #666666; font-style: italic;"># Interface Rede local</span>
&nbsp;
<span style="color: #007800;">GATEWAY_IP</span>=<span style="color: #ff0000;">&quot;192.168.254.254&quot;</span>
<span style="color: #007800;">NETMASK</span>=<span style="color: #ff0000;">&quot;255.255.255.0&quot;</span>
<span style="color: #007800;">CLASSE_LAN1</span>=<span style="color: #ff0000;">&quot;192.168.254&quot;</span>                    <span style="color: #666666; font-style: italic;"># Classe de IP utilizada na rede local. Ex.: 10.0</span>
<span style="color: #007800;">PROXY_SERVER</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$GATEWAY_IP</span>:3128&quot;</span>              <span style="color: #666666; font-style: italic;"># O proprio gateway tambem roda o Squid na porta 3128</span>
&nbsp;
<span style="color: #007800;">DHCPD_DAEMON</span>=<span style="color: #ff0000;">&quot;/etc/init.d/dhcp3-server&quot;</span>      <span style="color: #666666; font-style: italic;"># Executavel do dhcpd server</span>
<span style="color: #007800;">DHCPDCONF</span>=<span style="color: #ff0000;">&quot;/etc/dhcp3/dhcpd.conf&quot;</span>            <span style="color: #666666; font-style: italic;"># Arquivo de configuracao do dhcpd</span>
<span style="color: #007800;">DOMINIO</span>=<span style="color: #ff0000;">&quot;gustavohenrique.net&quot;</span>                <span style="color: #666666; font-style: italic;"># Dominio ao qual a rede faz parte</span>
<span style="color: #007800;">DNS_SERVERS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$GATEWAY_IP</span>, 8.8.8.8, 4.2.2.2&quot;</span>  <span style="color: #666666; font-style: italic;"># Servidores DNS. O primeiro é o próprio gateway</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Remove o controle de banda</span>
<span style="color: #000000; font-weight: bold;">function</span> parar_controle_de_banda <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #007800;">$TC</span> qdisc del dev <span style="color: #007800;">$I_LAN1</span> root
    <span style="color: #007800;">$TC</span> qdisc del dev <span style="color: #007800;">$I_WAN</span> root
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Cria as regras iniciais para controle de banda</span>
<span style="color: #000000; font-weight: bold;">function</span> iniciar_controle_de_banda <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #666666; font-style: italic;"># Remove as regras do controle de banda</span>
    parar_controle_de_banda
&nbsp;
    <span style="color: #666666; font-style: italic;"># Download</span>
    <span style="color: #007800;">$TC</span> qdisc add dev <span style="color: #007800;">$I_LAN1</span> root handle <span style="color: #000000;">1</span> cbq bandwidth 100Mbit avpkt <span style="color: #000000;">1000</span> cell <span style="color: #000000;">8</span>
    <span style="color: #007800;">$TC</span> class change dev <span style="color: #007800;">$I_LAN1</span> root cbq weight 10Mbit allot <span style="color: #000000;">1514</span>
&nbsp;
    <span style="color: #666666; font-style: italic;"># Upload</span>
    <span style="color: #007800;">$TC</span> qdisc add dev <span style="color: #007800;">$I_WAN</span> root handle <span style="color: #000000;">1</span> cbq bandwidth 100Mbit avpkt <span style="color: #000000;">1000</span> cell <span style="color: #000000;">8</span>
    <span style="color: #007800;">$TC</span> class change dev <span style="color: #007800;">$I_WAN</span> root cbq weight 10Mbit allot <span style="color: #000000;">1514</span>
&nbsp;
    <span style="color: #666666; font-style: italic;"># Cache Full. Pacotes marcados com TOS 60 vao para a classe 1:9999 cuja banda é 100 Mbit (rede ethernet)</span>
    <span style="color: #007800;">$TC</span> class add dev <span style="color: #007800;">$I_LAN1</span> parent <span style="color: #000000;">1</span>: classid <span style="color: #000000;">1</span>:<span style="color: #000000;">9999</span> cbq bandwidth 100Mbit rate 100Mbit weight 10Mbit prio <span style="color: #000000;">4</span> allot <span style="color: #000000;">1514</span> cell <span style="color: #000000;">8</span> maxburst <span style="color: #000000;">20</span> avpkt <span style="color: #000000;">1000</span> bounded
    <span style="color: #007800;">$TC</span> filter add dev <span style="color: #007800;">$I_LAN1</span> parent <span style="color: #000000;">1</span>:<span style="color: #000000;">0</span> protocol ip prio <span style="color: #000000;">3</span> u32 match ip protocol 0x6 0xff match ip tos <span style="color: #000000;">60</span> 0xff classid <span style="color: #000000;">1</span>:<span style="color: #000000;">9999</span>  
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;"># Limpa o firewall</span>
<span style="color: #000000; font-weight: bold;">function</span> parar_firewall<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #666666; font-style: italic;"># Configura a politca padrao para aceitar tudo</span>
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-P</span> INPUT ACCEPT
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-P</span> OUTPUT ACCEPT
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-P</span> FORWARD ACCEPT
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-P</span> PREROUTING ACCEPT
&nbsp;
    <span style="color: #666666; font-style: italic;"># Limpa a tabela netfilter</span>
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-F</span>
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-X</span>
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-F</span>
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-X</span>
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-t</span> mangle <span style="color: #660033;">-F</span>
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-t</span> mangle <span style="color: #660033;">-X</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;"># Cria as regras de firewall</span>
<span style="color: #000000; font-weight: bold;">function</span> iniciar_firewall<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;"># Finaliza o script se nao existir o arquivo contendo os pontos de rede</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$ARQUIVO</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Arquivo contendo os pontos de rede (<span style="color: #007800;">$ARQUIVO</span>) nao existe.&quot;</span>;
        <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
    <span style="color: #666666; font-style: italic;"># Carrega modulos do iptables</span>
    <span style="color: #007800;">$MOD</span> ip_tables
    <span style="color: #007800;">$MOD</span> iptable_nat
    <span style="color: #007800;">$MOD</span> ipt_MASQUERADE
    <span style="color: #007800;">$MOD</span> ipt_LOG
    <span style="color: #007800;">$MOD</span> ipt_REJECT
    <span style="color: #007800;">$MOD</span> ip_conntrack_ftp
    <span style="color: #007800;">$MOD</span> ip_nat_ftp
&nbsp;
    <span style="color: #666666; font-style: italic;"># Limpa todas as regras do firewall</span>
    parar_firewall
&nbsp;
    <span style="color: #666666; font-style: italic;"># Recria as regras para controle de banda</span>
    iniciar_controle_de_banda
&nbsp;
    <span style="color: #666666; font-style: italic;"># Por padrao bloqueia tudo que for entrar no firewall</span>
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-P</span> INPUT DROP
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-P</span> PREROUTING DROP
&nbsp;
    <span style="color: #666666; font-style: italic;"># Habilita redirecionamento de pacotes para compartilhar internet</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span>sys<span style="color: #000000; font-weight: bold;">/</span>net<span style="color: #000000; font-weight: bold;">/</span>ipv4<span style="color: #000000; font-weight: bold;">/</span>ip_forward
&nbsp;
    <span style="color: #666666; font-style: italic;"># Aumenta o limite do nf_conntrack_max</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000;">99999</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span>sys<span style="color: #000000; font-weight: bold;">/</span>net<span style="color: #000000; font-weight: bold;">/</span>netfilter<span style="color: #000000; font-weight: bold;">/</span>nf_conntrack_max
&nbsp;
    <span style="color: #666666; font-style: italic;"># Libera acesso para pacotes vindos da internet (CUIDADO)</span>
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-A</span> PREROUTING <span style="color: #660033;">-s</span> <span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span> <span style="color: #660033;">-i</span> <span style="color: #007800;">$I_WAN</span> <span style="color: #660033;">-p</span> all <span style="color: #660033;">-j</span> ACCEPT
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-i</span> <span style="color: #007800;">$I_WAN</span> <span style="color: #660033;">-j</span> ACCEPT
&nbsp;
    <span style="color: #666666; font-style: italic;"># Cria uma nova chain para tratar do proxy transparente</span>
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-N</span> proxy
        <span style="color: #666666; font-style: italic;"># O software conectividade social da Caixa Economica nao funciona se</span>
        <span style="color: #666666; font-style: italic;"># estiver passando pelo proxy. Tudo que for destinado ao IP da Caixa</span>
        <span style="color: #666666; font-style: italic;"># nao vai passar pelo proxy</span>
        <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-A</span> proxy <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-d</span> 200.201.174.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">16</span> <span style="color: #660033;">--dport</span> <span style="color: #000000;">80</span> <span style="color: #660033;">-j</span> ACCEPT
        <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-A</span> proxy <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-d</span> 200.201.173.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">16</span> <span style="color: #660033;">--dport</span> <span style="color: #000000;">80</span> <span style="color: #660033;">-j</span> ACCEPT
        <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-A</span> proxy <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-d</span> 200.201.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">16</span> <span style="color: #660033;">--dport</span> <span style="color: #000000;">80</span> <span style="color: #660033;">-j</span> ACCEPT
        <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-A</span> proxy <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-d</span> 200.201.174.207 <span style="color: #660033;">--dport</span> <span style="color: #000000;">80</span> <span style="color: #660033;">-j</span> ACCEPT
&nbsp;
        <span style="color: #666666; font-style: italic;"># Internet Caixa nao passa pelo proxy</span>
        <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-A</span> proxy <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-d</span> 200.201.169.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8</span> <span style="color: #660033;">--dport</span> <span style="color: #000000;">80</span> <span style="color: #660033;">-j</span> ACCEPT
        <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-A</span> proxy <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-d</span> 200.201.169.69 <span style="color: #660033;">--dport</span> <span style="color: #000000;">80</span> <span style="color: #660033;">-j</span> ACCEPT
&nbsp;
        <span style="color: #666666; font-style: italic;"># Esse servidor tambem roda o Apache na port 80. Nao quero que as</span>
        <span style="color: #666666; font-style: italic;"># paginas locais passem pelo proxy, pois assim posso controlar a banda</span>
        <span style="color: #666666; font-style: italic;"># de pacotes vindos do apache definindo a velocidade máxima da rede</span>
        <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-A</span> proxy <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-d</span> <span style="color: #007800;">$GATEWAY_IP</span> <span style="color: #660033;">--dport</span> <span style="color: #000000;">80</span> <span style="color: #660033;">-j</span> ACCEPT
&nbsp;
        <span style="color: #666666; font-style: italic;"># Proxy transparente redirecionando os pacotes para a porta do Squid</span>
        <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-A</span> proxy <span style="color: #660033;">-s</span> <span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span> <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">80</span> <span style="color: #660033;">-j</span> DNAT <span style="color: #660033;">--to-dest</span> <span style="color: #007800;">$PROXY_SERVER</span>
&nbsp;
        <span style="color: #666666; font-style: italic;"># Se o pacote nao for pra porta 80 (não é navegação), deixa passar</span>
        <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-A</span> proxy <span style="color: #660033;">-i</span> <span style="color: #007800;">$I_LAN1</span> <span style="color: #660033;">-j</span> ACCEPT
&nbsp;
&nbsp;
    <span style="color: #666666; font-style: italic;"># Libera o IP abaixo sem amarrar com MAC e sem passar pelo proxy</span>
    <span style="color: #666666; font-style: italic;">#$IPT -t nat -A PREROUTING -i $I_LAN1 -s 192.168.254.2 -j ACCEPT</span>
&nbsp;
    <span style="color: #666666; font-style: italic;"># Configuracao inicial do dhcpd.conf. Distribuicao de IPs na faixa 192.168.254.80 a 192.168.254.90</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;# Arquivo dhcpd.conf criado pelo BandControl&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$DHCPDCONF</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;ddns-update-style none;&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$DHCPDCONF</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;option domain-name <span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #007800;">$DOMINIO</span><span style="color: #000099; font-weight: bold;">\&quot;</span>;&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$DHCPDCONF</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;option domain-name-servers <span style="color: #007800;">$DNS_SERVERS</span>;&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$DHCPDCONF</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;default-lease-time 600;&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$DHCPDCONF</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;max-lease-time 7200;&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$DHCPDCONF</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;authoritative;&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$DHCPDCONF</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;shared-network 0-2 {&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$DHCPDCONF</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;  subnet <span style="color: #007800;">$CLASSE_LAN1</span>&quot;</span>.<span style="color: #ff0000;">&quot;0 netmask <span style="color: #007800;">$NETMASK</span> { range <span style="color: #007800;">$CLASSE_LAN1</span>.80 <span style="color: #007800;">$CLASSE_LAN1</span>.90; }&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$DHCPDCONF</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;}&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$DHCPDCONF</span>
&nbsp;
    <span style="color: #666666; font-style: italic;"># Inicio do loop para liberacao e bloqueio de clientes.</span>
    <span style="color: #666666; font-style: italic;"># O formato do arquivo é: codigo_identificador-descricao-ip-mac-download-upload-liberado-proxy</span>
    <span style="color: #666666; font-style: italic;"># Ex.: 1-gustavo_henrique_notebook-192.168.254.10-512-256-S-S</span>
    <span style="color: #666666; font-style: italic;"># Acesso liberado e uso do proxy sao valores que devem ser True ou False</span>
    <span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$ARQUIVO</span><span style="color: #000000; font-weight: bold;">`</span>; <span style="color: #000000; font-weight: bold;">do</span>
        <span style="color: #007800;">CODIGO</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$i</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span> <span style="color: #ff0000;">&quot;-&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #ff0000;">'print $1'</span><span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>                  <span style="color: #666666; font-style: italic;"># Numero usado como identificador no controle de banda</span>
        <span style="color: #007800;">IP</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$i</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span> <span style="color: #ff0000;">&quot;-&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #ff0000;">'print $3'</span><span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>                      <span style="color: #666666; font-style: italic;"># IP</span>
        <span style="color: #007800;">MAC</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$i</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span> <span style="color: #ff0000;">&quot;-&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #ff0000;">'print $4'</span><span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>                     <span style="color: #666666; font-style: italic;"># MAC em letras minusculas e separado por dois pontos (:)</span>
        <span style="color: #007800;">DOWNLOAD</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$i</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span> <span style="color: #ff0000;">&quot;-&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #ff0000;">'print $5'</span><span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>                <span style="color: #666666; font-style: italic;"># Numero correspondente a velocidade de download em Kbit</span>
        <span style="color: #007800;">UPLOAD</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$i</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span> <span style="color: #ff0000;">&quot;-&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #ff0000;">'print $6'</span><span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>                  <span style="color: #666666; font-style: italic;"># Numero correspondente a velocidade de upload em Kbit</span>
        <span style="color: #007800;">POSSUI_ACESSO_LIBERADO</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$i</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span> <span style="color: #ff0000;">&quot;-&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #ff0000;">'print $7'</span><span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>  <span style="color: #666666; font-style: italic;"># True para sim, False para bloquear o acesso</span>
        <span style="color: #007800;">VAI_USAR_PROXY</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$i</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #660033;">-F</span> <span style="color: #ff0000;">&quot;-&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #ff0000;">'print $8'</span><span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>          <span style="color: #666666; font-style: italic;"># True para usar o proxy, False para não usar</span>
&nbsp;
        <span style="color: #666666; font-style: italic;"># Configurar dhcpd para associar IP ao MAC</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$MAC</span>&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
          <span style="color: #007800;">LINHA</span>=<span style="color: #ff0000;">&quot;host <span style="color: #007800;">$CODIGO</span> { hardware ethernet <span style="color: #007800;">$MAC</span>; fixed-address <span style="color: #007800;">$IP</span>; option subnet-mask <span style="color: #007800;">$NETMASK</span>; option routers <span style="color: #007800;">$GATEWAY_IP</span>; option domain-name-servers <span style="color: #007800;">$DNS_SERVERS</span>; }&quot;</span>
          <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$LINHA</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #007800;">$DHCPDCONF</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
        <span style="color: #666666; font-style: italic;"># Se o IP nao esta liberado, bloqueia no firewall</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$POSSUI_ACESSO_LIBERADO</span>&quot;</span> == <span style="color: #ff0000;">&quot;False&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
            <span style="color: #007800;">EXECUTAR_REGRA</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$IPT</span> -t nat -A PREROUTING -p tcp -i <span style="color: #007800;">$I_LAN1</span> -s <span style="color: #007800;">$IP</span> -j DROP&quot;</span>
        <span style="color: #000000; font-weight: bold;">else</span>
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$VAI_USAR_PROXY</span>&quot;</span> == <span style="color: #ff0000;">&quot;True&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
                <span style="color: #007800;">EXECUTAR_REGRA</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$IPT</span> -t nat -A PREROUTING -i <span style="color: #007800;">$I_LAN1</span> -s <span style="color: #007800;">$IP</span> -m mac --mac-source <span style="color: #007800;">$MAC</span> -j proxy&quot;</span>
            <span style="color: #000000; font-weight: bold;">else</span>
                <span style="color: #007800;">EXECUTAR_REGRA</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$IPT</span> -t nat -A PREROUTING -i <span style="color: #007800;">$I_LAN1</span> -s <span style="color: #007800;">$IP</span> -j ACCEPT&quot;</span>
            <span style="color: #000000; font-weight: bold;">fi</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
        <span style="color: #666666; font-style: italic;"># Executa a regra referente ao IP dentro do loop</span>
        <span style="color: #007800;">$EXECUTAR_REGRA</span>
&nbsp;
&nbsp;
        <span style="color: #666666; font-style: italic;"># Aplica o controle de banda ao IP. Para cada IP é criada uma classe de download e upload.</span>
        <span style="color: #007800;">WEIGHT_DOWN</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">expr</span> <span style="color: #007800;">$DOWNLOAD</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000;">10</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #007800;">ID_DOWN</span>=<span style="color: #000000;">1</span><span style="color: #ff0000;">&quot;<span style="color: #007800;">$CODIGO</span>&quot;</span>
        <span style="color: #007800;">$TC</span> class add dev <span style="color: #007800;">$I_LAN1</span> parent <span style="color: #000000;">1</span>: classid <span style="color: #000000;">1</span>:<span style="color: #007800;">$ID_DOWN</span> cbq bandwidth 10Mbit rate <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DOWNLOAD</span>&quot;</span>Kbit weight <span style="color: #ff0000;">&quot;<span style="color: #007800;">$WEIGHT_DOWN</span>&quot;</span>Kbit prio <span style="color: #000000;">5</span> allot <span style="color: #000000;">1514</span> cell <span style="color: #000000;">8</span> maxburst <span style="color: #000000;">20</span> avpkt <span style="color: #000000;">1000</span> bounded
        <span style="color: #007800;">$TC</span> filter add dev <span style="color: #007800;">$I_LAN1</span> parent <span style="color: #000000;">1</span>:<span style="color: #000000;">0</span> protocol ip prio <span style="color: #000000;">100</span> u32 match ip dst <span style="color: #007800;">$IP</span> classid <span style="color: #000000;">1</span>:<span style="color: #007800;">$ID_DOWN</span>
&nbsp;
        <span style="color: #007800;">WEIGHT_UP</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">expr</span> <span style="color: #007800;">$UPLOAD</span> <span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000;">10</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #007800;">ID_UP</span>=<span style="color: #000000;">2</span><span style="color: #ff0000;">&quot;<span style="color: #007800;">$CODIGO</span>&quot;</span>
        <span style="color: #007800;">$TC</span> class add dev <span style="color: #007800;">$I_WAN</span> parent <span style="color: #000000;">1</span>: classid <span style="color: #000000;">1</span>:<span style="color: #007800;">$ID_UP</span> cbq bandwidth 10Mbit rate <span style="color: #ff0000;">&quot;<span style="color: #007800;">$UPLOAD</span>&quot;</span>Kbit weight <span style="color: #ff0000;">&quot;<span style="color: #007800;">$WEIGHT_UP</span>&quot;</span>Kbit prio <span style="color: #000000;">5</span> allot <span style="color: #000000;">1514</span> cell <span style="color: #000000;">8</span> maxburst <span style="color: #000000;">20</span> avpkt <span style="color: #000000;">1000</span> bounded
        <span style="color: #007800;">$TC</span> qdisc add dev <span style="color: #007800;">$I_WAN</span> parent <span style="color: #000000;">1</span>:<span style="color: #007800;">$ID_UP</span> handle <span style="color: #007800;">$ID_UP</span> tbf rate <span style="color: #ff0000;">&quot;<span style="color: #007800;">$UPLOAD</span>&quot;</span>Kbit buffer 10Kb<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8</span> limit 15Kb mtu <span style="color: #000000;">1500</span>
        <span style="color: #007800;">$TC</span> filter add dev <span style="color: #007800;">$I_WAN</span> parent <span style="color: #000000;">1</span>:<span style="color: #000000;">0</span> protocol ip prio <span style="color: #000000;">100</span> u32 match ip src <span style="color: #007800;">$IP</span> classid <span style="color: #000000;">1</span>:<span style="color: #007800;">$ID_UP</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
    <span style="color: #666666; font-style: italic;"># Aplica o TOS 60 nas portas utilizadas por outros serviços. Assim é usado a velocidade total da rede</span>
    <span style="color: #666666; font-style: italic;"># para acesso ao SSH, Apache e Samba</span>
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-t</span> mangle <span style="color: #660033;">-A</span> OUTPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--sport</span> <span style="color: #000000;">22</span> <span style="color: #660033;">-j</span> TOS <span style="color: #660033;">--set-tos</span> <span style="color: #000000;">60</span>
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-t</span> mangle <span style="color: #660033;">-A</span> OUTPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--sport</span> <span style="color: #000000;">80</span> <span style="color: #660033;">-j</span> TOS <span style="color: #660033;">--set-tos</span> <span style="color: #000000;">60</span>
&nbsp;
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-t</span> mangle <span style="color: #660033;">-A</span> OUTPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--sport</span> <span style="color: #000000;">137</span>:<span style="color: #000000;">139</span> <span style="color: #660033;">-j</span> TOS <span style="color: #660033;">--set-tos</span> <span style="color: #000000;">60</span>
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-t</span> mangle <span style="color: #660033;">-A</span> OUTPUT <span style="color: #660033;">-p</span> udp <span style="color: #660033;">--sport</span> <span style="color: #000000;">137</span>:<span style="color: #000000;">139</span> <span style="color: #660033;">-j</span> TOS <span style="color: #660033;">--set-tos</span> <span style="color: #000000;">60</span>
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-t</span> mangle <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">137</span>:<span style="color: #000000;">139</span> <span style="color: #660033;">-j</span> TOS <span style="color: #660033;">--set-tos</span> <span style="color: #000000;">60</span>
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-t</span> mangle <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> udp <span style="color: #660033;">--dport</span> <span style="color: #000000;">137</span>:<span style="color: #000000;">139</span> <span style="color: #660033;">-j</span> TOS <span style="color: #660033;">--set-tos</span> <span style="color: #000000;">60</span>
&nbsp;
    <span style="color: #666666; font-style: italic;"># Compartilha a internet</span>
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-A</span> POSTROUTING <span style="color: #660033;">-o</span> <span style="color: #007800;">$I_WAN</span> <span style="color: #660033;">-j</span> MASQUERADE
&nbsp;
    <span style="color: #666666; font-style: italic;"># Bloqueio contra Scanners Ocultos (Shealt Scan)</span>
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--tcp-flags</span> SYN,ACK,FIN,RST RST <span style="color: #660033;">-m</span> limit <span style="color: #660033;">--limit</span> <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">/</span>s <span style="color: #660033;">-j</span> DROP
&nbsp;
    <span style="color: #666666; font-style: italic;"># Libera ping (CUIDADO com ataques ddos)</span>
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-i</span> <span style="color: #007800;">$I_LAN1</span> <span style="color: #660033;">-p</span> icmp <span style="color: #660033;">-j</span> ACCEPT
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-i</span> <span style="color: #007800;">$I_WAN</span> <span style="color: #660033;">-p</span> icmp <span style="color: #660033;">-j</span> ACCEPT
&nbsp;
    <span style="color: #666666; font-style: italic;"># Libera acesso para o proprio gateway</span>
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-i</span> lo <span style="color: #660033;">-j</span> ACCEPT
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> FORWARD <span style="color: #660033;">-i</span> lo <span style="color: #660033;">-j</span> ACCEPT
&nbsp;
    <span style="color: #666666; font-style: italic;"># Libera acesso ao Apache</span>
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">80</span> <span style="color: #660033;">-j</span> ACCEPT
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">443</span> <span style="color: #660033;">-j</span> ACCEPT
&nbsp;
    <span style="color: #666666; font-style: italic;"># Libera acesso ao Squid</span>
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">3128</span> <span style="color: #660033;">-j</span> ACCEPT
&nbsp;
    <span style="color: #666666; font-style: italic;"># Libera acesso ao SSH</span>
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">22</span> <span style="color: #660033;">-j</span> ACCEPT
&nbsp;
    <span style="color: #666666; font-style: italic;"># Libera acesso ao DNS</span>
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> udp <span style="color: #660033;">--dport</span> <span style="color: #000000;">53</span> <span style="color: #660033;">-j</span> ACCEPT
&nbsp;
    <span style="color: #666666; font-style: italic;"># Libera acesso aos compartilhamentos do Samba</span>
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">137</span>:<span style="color: #000000;">139</span> <span style="color: #660033;">-j</span> ACCEPT
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> udp <span style="color: #660033;">--dport</span> <span style="color: #000000;">137</span>:<span style="color: #000000;">139</span> <span style="color: #660033;">-j</span> ACCEPT
&nbsp;
    <span style="color: #666666; font-style: italic;"># Libera acesso ao SNMP</span>
    <span style="color: #666666; font-style: italic;">#$IPT -A INPUT -p udp --dport 160:162 -j ACCEPT</span>
&nbsp;
    <span style="color: #666666; font-style: italic;"># Tratamento de conexoes TCP</span>
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--syn</span> <span style="color: #660033;">-j</span> DROP
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-m</span> state <span style="color: #660033;">--state</span> ESTABLISHED,RELATED,NEW <span style="color: #660033;">-j</span> ACCEPT
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-m</span> limit <span style="color: #660033;">--limit</span> <span style="color: #000000;">3</span><span style="color: #000000; font-weight: bold;">/</span>minute <span style="color: #660033;">--limit-burst</span> <span style="color: #000000;">3</span> <span style="color: #660033;">-j</span> DROP
&nbsp;
    <span style="color: #666666; font-style: italic;"># Bloqueando pacotes estranhos</span>
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--tcp-flags</span> ALL FIN,URG,PSH <span style="color: #660033;">-j</span> DROP
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--tcp-flags</span> ALL SYN,RST,ACK,FIN,URG <span style="color: #660033;">-j</span> DROP
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--tcp-flags</span> ALL ALL <span style="color: #660033;">-j</span> DROP
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--tcp-flags</span> ALL FIN <span style="color: #660033;">-j</span> DROP
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--tcp-flags</span> SYN,RST SYN,RST <span style="color: #660033;">-j</span> DROP
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--tcp-flags</span> SYN,FIN SYN,FIN <span style="color: #660033;">-j</span> DROP
    <span style="color: #007800;">$IPT</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--tcp-flags</span> ALL NONE <span style="color: #660033;">-j</span> DROP
&nbsp;
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Firewall iniciado&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">case</span> $<span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">in</span>
    <span style="color: #666666; font-style: italic;"># Inicia o firewall e o dhcpd</span>
    start<span style="color: #7a0874; font-weight: bold;">&#41;</span> iniciar_firewall; <span style="color: #007800;">$DHCPD_DAEMON</span> stop; <span style="color: #007800;">$DHCPD_DAEMON</span> start; <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000; font-weight: bold;">;;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;"># Finaliza o firewall sem parar o dhcp</span>
    stop<span style="color: #7a0874; font-weight: bold;">&#41;</span> parar_firewall; <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000; font-weight: bold;">;;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;"># Inicia o firewall sem reiniciar o dhcpd</span>
    only<span style="color: #7a0874; font-weight: bold;">&#41;</span> iniciar_firewall; <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000; font-weight: bold;">;;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;"># Finaliza o controle de banda</span>
    fast<span style="color: #7a0874; font-weight: bold;">&#41;</span> parar_controle_de_banda; <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000; font-weight: bold;">;;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;"># Se nenhum parametro for passado, mostra a ajuda abaixo</span>
    <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Use assim: $0 start|stop|only|fast&quot;</span>; <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #000000; font-weight: bold;">esac</span></pre></div></div>

<h2>Conclusão</h2>
<p>Com o término da segunda parte do artigo é possível colocar um servidor Linux funcionando com eficiência, segurança e estabilidade para compartilhar uma conexão de internet. É uma ótima solução custo/benefício para micro e pequenas empresas.<br />
Na próxima parte vou mostrar como desenvolver uma interface web para gerenciar melhor os pontos de rede. Isso dá mais agilidade ao trabalhar com muitas máquinas na rede.</p>
<p>Algumas considerações:</p>
<ul>
<li>Tomem cuidado na configuração do firewall. Esse é um script simples que serve não deve ser tomado como solução definitiva.</li>
<li>Há outra alternativa para controle de banda chamada HTB. Pessoalmente prefiro o CBQ, o mesmo utilizado nesse script, mas vale a pena dar uma estudada.</li>
<li>Usar um arquivo texto contendo os dados dos pontos de rede para ser lido pelo shell script foi a idéia mais simples e não a de melhor desempenho. Também fiz o script fazer consultas ao MySQL mas não senti diferença na velocidade comparado com a leitura de um arquivo de texto.</li>
</ul>
<p>Bom, a parte 3 do artigo só em 2010. Nesse momento já estou em algum lugar sem internet e talvez sem celular. <img src='http://www.gustavohenrique.net/brogui/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /><br />
Feliz ano novo à todos!</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Compartilhe esse artigo</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http://www.gustavohenrique.net/brogui/2009/12/servidor-linux-com-proxy-e-controle-de-banda-parte-2/&amp;submitHeadline=Servidor+Linux+com+Proxy+e+Controle+de+Banda+%26%238211%3B+Parte+2&amp;submitSummary=" rel="nofollow" title="Adicionar ao&nbsp;Buzz"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/buzz.png" title="Adicionar ao&nbsp;Buzz" alt="Adicionar ao&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.gustavohenrique.net/brogui/2009/12/servidor-linux-com-proxy-e-controle-de-banda-parte-2/&amp;title=Servidor+Linux+com+Proxy+e+Controle+de+Banda+%26%238211%3B+Parte+2" rel="nofollow" title="Adicionar ao&nbsp;Del.icio.us"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/delicious.png" title="Adicionar ao&nbsp;Del.icio.us" alt="Adicionar ao&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.gustavohenrique.net/brogui/2009/12/servidor-linux-com-proxy-e-controle-de-banda-parte-2/&amp;title=Servidor+Linux+com+Proxy+e+Controle+de+Banda+%26%238211%3B+Parte+2" rel="nofollow" title="Adicionar ao&nbsp;digg"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/digg.png" title="Adicionar ao&nbsp;digg" alt="Adicionar ao&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://www.gustavohenrique.net/brogui/2009/12/servidor-linux-com-proxy-e-controle-de-banda-parte-2/" rel="nofollow" title="Adicionar ao&nbsp;Facebook"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/facebook.png" title="Adicionar ao&nbsp;Facebook" alt="Adicionar ao&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://www.gustavohenrique.net/brogui/2009/12/servidor-linux-com-proxy-e-controle-de-banda-parte-2/&amp;title=Servidor+Linux+com+Proxy+e+Controle+de+Banda+%26%238211%3B+Parte+2" rel="nofollow" title="Adicionar ao&nbsp;Google Bookmarks"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/google.png" title="Adicionar ao&nbsp;Google Bookmarks" alt="Adicionar ao&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http://www.gustavohenrique.net/brogui/2009/12/servidor-linux-com-proxy-e-controle-de-banda-parte-2/&amp;bm_description=Servidor+Linux+com+Proxy+e+Controle+de+Banda+%26%238211%3B+Parte+2" rel="nofollow" title="Adicionar ao&nbsp;Mister Wong"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Adicionar ao&nbsp;Mister Wong" alt="Adicionar ao&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://www.gustavohenrique.net/brogui/2009/12/servidor-linux-com-proxy-e-controle-de-banda-parte-2/&amp;T=Servidor+Linux+com+Proxy+e+Controle+de+Banda+%26%238211%3B+Parte+2" rel="nofollow" title="Adicionar ao&nbsp;Netscape"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/netscape.png" title="Adicionar ao&nbsp;Netscape" alt="Adicionar ao&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://www.gustavohenrique.net/brogui/2009/12/servidor-linux-com-proxy-e-controle-de-banda-parte-2/&amp;title=Servidor+Linux+com+Proxy+e+Controle+de+Banda+%26%238211%3B+Parte+2" rel="nofollow" title="Adicionar ao&nbsp;reddit"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/reddit.png" title="Adicionar ao&nbsp;reddit" alt="Adicionar ao&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.gustavohenrique.net/brogui/2009/12/servidor-linux-com-proxy-e-controle-de-banda-parte-2/&amp;title=Servidor+Linux+com+Proxy+e+Controle+de+Banda+%26%238211%3B+Parte+2" rel="nofollow" title="Adicionar ao&nbsp;Stumble Upon"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Adicionar ao&nbsp;Stumble Upon" alt="Adicionar ao&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://www.gustavohenrique.net/brogui/2009/12/servidor-linux-com-proxy-e-controle-de-banda-parte-2/" rel="nofollow" title="Adicionar ao&nbsp;Technorati"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/technorati.png" title="Adicionar ao&nbsp;Technorati" alt="Adicionar ao&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http://www.gustavohenrique.net/brogui/2009/12/servidor-linux-com-proxy-e-controle-de-banda-parte-2/" rel="nofollow" title="Adicionar ao&nbsp;Tip'd"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/tipd.png" title="Adicionar ao&nbsp;Tip'd" alt="Adicionar ao&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Servidor+Linux+com+Proxy+e+Controle+de+Banda+%26%238211%3B+Parte+2+@+http://www.gustavohenrique.net/brogui/2009/12/servidor-linux-com-proxy-e-controle-de-banda-parte-2/" rel="nofollow" title="Adicionar ao&nbsp;Twitter"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/twitter.png" title="Adicionar ao&nbsp;Twitter" alt="Adicionar ao&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://www.gustavohenrique.net/brogui/2009/12/servidor-linux-com-proxy-e-controle-de-banda-parte-2/&amp;t=Servidor+Linux+com+Proxy+e+Controle+de+Banda+%26%238211%3B+Parte+2" rel="nofollow" title="Adicionar ao&nbsp;Yahoo My Web"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Adicionar ao&nbsp;Yahoo My Web" alt="Adicionar ao&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.gustavohenrique.net/brogui/2009/12/servidor-linux-com-proxy-e-controle-de-banda-parte-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Servidor Linux com Proxy e Controle de Banda &#8211; Parte 1</title>
		<link>http://www.gustavohenrique.net/brogui/2009/12/servidor-linux-com-proxy-e-controle-de-banda-parte-1/</link>
		<comments>http://www.gustavohenrique.net/brogui/2009/12/servidor-linux-com-proxy-e-controle-de-banda-parte-1/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 12:09:38 +0000</pubDate>
		<dc:creator>gustavohenrique</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[firewall]]></category>
		<category><![CDATA[proxy]]></category>

		<guid isPermaLink="false">http://www.gustavohenrique.net/brogui/?p=173</guid>
		<description><![CDATA[
Vou mostrar como configurar um servidor Linux para compartilhar a internet de maneira mais segura com firewall bloqueando máquinas não cadastradas, proxy Squid fazendo cache full e controle de banda com CBQ.
Um servidor desse tipo é uma excelente opção custo/benefício para pequenas e médias empresas, para pequenos provedores de internet (ISP) ou mesmo para quem [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.gustavohenrique.net/brogui/wp-content/uploads/2009/12/linux-penguin.jpg"><img src="http://www.gustavohenrique.net/brogui/wp-content/uploads/2009/12/linux-penguin.jpg" alt="Tux" title="Tux" width="300" height="224" class="aligncenter size-full wp-image-179" /></a><br />
Vou mostrar como configurar um servidor Linux para compartilhar a internet de maneira mais segura com firewall bloqueando máquinas não cadastradas, proxy Squid fazendo cache full e controle de banda com CBQ.<br />
Um servidor desse tipo é uma excelente opção custo/benefício para pequenas e médias empresas, para pequenos provedores de internet (ISP) ou mesmo para quem deseja apenas compartilhar a internet entre vizinhos.<br />
Dessa vez é um artigo mais prático e menos teórico. Não vou entrar em explicações sobre o que é um proxy, como funciona o controle de banda ou tabelas do iptables.<br />
O artigo foi divido em 3 partes:</p>
<p>1. Instalação do Squid com o patch ZPH (para fazer cache full)<br />
2. Configuração do script de firewall e controle de banda<br />
3. Interface web (desenvolvida em Django) para gerenciar o firewall<br />
<span id="more-173"></span></p>
<h2>Introdução</h2>
<p>O uso do GNU/Linux em servidores vem crescendo a cada ano. Não só pelo custo zero com licenças mas também por sua superior vantagem em desempenho, segurança e estabilidade em relação à outros sistemas operacionais.<br />
Graças ao Linux e aos softwares open source descritos nesse artigo é possível criar uma solução economicamente viável para empresas que ainda não dispõem de uma estrutura adequada para compartilhar a internet.<br />
Nesse exemplo vamos instalar o proxy Squid na mesma máquina que funciona como gateway. Com o crescimento da rede, é aconselhável separar um ou mais servidores apenas para proxy e definindo as rotas manualmente no gateway.<br />
A distribuição utilizada foi Ubuntu Server 9.04 mas nada impede que seja aplicada à outras distros.</p>
<h2>Compilando o Squid com suporte a Cache Full</h2>
<p>Cache full é a ação de fazer com que os arquivos em cache utilizem uma velocidade maior independente do controle de banda definido para as máquinas clientes. Com o proxy Squid, alguns arquivos ficam em cache, ou seja, ficam no HD do seu servidor. Então quando um cliente acessa um site que contém algumas imagens em cache, o Squid não baixa novamente essas imagens, ele envia o que está armazenado no HD. Se arquivos em cache estão vindo do HD do servidor de proxy, então por que não usar a velocidade da rede (10/100 Ethernet por exemplo) para enviar esses arquivos aos clientes já que não consome o link de internet? É até melhor pois o carregamento do site fica mais rápido.<br />
Existe um patch para o squid, chamado de ZPH, que faz uma marcação nos pacotes que estão em cache, e sabendo dessa marcação podemos definir uma velocidade no controle de banda para esses pacotes.<br />
O patch ZPH <span style="color:red">NÃO</span> funciona com qualquer versão do Squid. Até o momento em que estou escrevendo a última versão do Squid compatível é a 3.0STABLE8.<br />
Vou baixar o código fonte do squid, o patch ZPH, aplicar o patch, compilar e instalar o Squid. Chega de teorias:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">root@localhost:~# wget http://zph.bratcheda.org/squid-3.0.STABLE8-zph.patch
root@localhost:~# apt-get source squid3
root@localhost:~# apt-get build-dep squid3
root@localhost:~# cd squid3-3.0.STABLE8
root@localhost:~/squid3-3.0.STABLE8# patch -p1 ../squid-3.0.STABLE8-zph.patch
root@localhost:~/squid3-3.0.STABLE8# dpkg-buildpackage -rfakeroot -uc -b</pre></div></div>

<p>Primeiro foi feito o download do patch ZPH usando o software wget. Depois foi baixado o source do squid3 diretamente dos repositórios do Ubuntu e então, usando o <code>apt-get build-dep squid3</code>, foi criado o diretório <code>squid3-3.0.STABLE8</code> e instaladas as dependências necessárias para compilar o squid. Após isso, entrei no diretório contendo o source do Squid, apliquei o patch ZPH (comando <code>patch -p1</code>) e com isso foram criados os pacotes no formato deb para instalação. Para instalar basta usar o <code>dpkg -i</code> em cada pacote no formato deb.</p>

<div class="wp_syntax"><div class="code"><pre class="diff" style="font-family:monospace;">root@localhost:~/squid3-3.0.STABLE8# cd ..
root@localhost:~# dpkg -i squid3_3.0.STABLE8-<span style="">3</span>+lenny2build0.9.04.1_i386.deb
root@localhost:~# dpkg -i squid3-common_3.0.STABLE8-<span style="">3</span>+lenny2build0.9.04.1_all.deb
root@localhost:~# dpkg -i squid3-cgi_3.0.STABLE8-<span style="">3</span>+lenny2build0.9.04.1_i386.deb
root@localhost:~# dpkg -i squidclient_3.0.STABLE8-<span style="">3</span>+lenny2build0.9.04.1_i386.deb</pre></div></div>

<h2>Configurando o squid.conf</h2>
<p>A localização do arquivo deve ser <code>/etc/squid3/squid.conf</code>.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl to_localhost dst 127.0.0.0/8
acl localnet src 192.168.254.0/24
acl SSL_ports port 443
acl Safe_ports port 80		# http
acl Safe_ports port 21		# ftp
acl Safe_ports port 443		# https
acl Safe_ports port 70		# gopher
acl Safe_ports port 210		# wais
acl Safe_ports port 1025-65535	# unregistered ports
acl Safe_ports port 280		# http-mgmt
acl Safe_ports port 488		# gss-http
acl Safe_ports port 591		# filemaker
acl Safe_ports port 777		# multiling http
acl CONNECT method CONNECT
&nbsp;
http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localnet
http_access deny all
&nbsp;
icp_access allow localnet
icp_access deny all
htcp_access allow localnet
htcp_access deny all
&nbsp;
# Porta
http_port 3128 transparent
&nbsp;
hierarchy_stoplist cgi-bin ?
maximum_object_size_in_memory 64 KB
cache_dir aufs /var/cache/squid 40000 16 256
max_open_disk_fds 0
&nbsp;
# Marcacao TOS do ZPH
zph_tos_local 16
zph_tos_parent on
&nbsp;
# Arquivos de LOG
access_log /var/log/squid3/access.log squid
cache_log /var/log/squid3/cache.log
cache_store_log /var/log/squid3/store.log
&nbsp;
# PID
pid_filename /var/run/squid.pid
&nbsp;
refresh_pattern ^ftp:		1440	20%	10080
refresh_pattern ^gopher:	1440	0%	1440
refresh_pattern (cgi-bin|\?)	0	0%	0
refresh_pattern .		0	20%	4320
visible_hostname mainserver
icp_port 3130
coredump_dir /var/cache</pre></div></div>

<p>Consulte a <a href="http://www.squid-cache.org" target="_blank">documentação do squid</a> para mais informações.</p>
<h2>Inciando o Squid</h2>
<p>Criando a estrutura de diretórios e iniciando o serviço:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">root@localhost:~# squid -z
root@localhost:~# /etc/init.d/squid3 start</pre></div></div>

<p>Para testar o funcionamento basta configurar o browser para acessar via proxy usando o IP 127.0.0.1 e porta 3128. Se navegar na internet significa que funcionou, se não, leia os arquivos de log para tentar identificar o problema.</p>
<h2>Conclusão</h2>
<p>É possível que ocorra algum problema seguindo os passos descritos nesse artigo. O motivo se deve ao fato de que tive que simplificar bastante os passos para servir como um exemplo genérico.<br />
Problemas ou dúvidas ficarei feliz em poder ajudar.<br />
Feliz natal à todos!</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Compartilhe esse artigo</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http://www.gustavohenrique.net/brogui/2009/12/servidor-linux-com-proxy-e-controle-de-banda-parte-1/&amp;submitHeadline=Servidor+Linux+com+Proxy+e+Controle+de+Banda+%26%238211%3B+Parte+1&amp;submitSummary=" rel="nofollow" title="Adicionar ao&nbsp;Buzz"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/buzz.png" title="Adicionar ao&nbsp;Buzz" alt="Adicionar ao&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.gustavohenrique.net/brogui/2009/12/servidor-linux-com-proxy-e-controle-de-banda-parte-1/&amp;title=Servidor+Linux+com+Proxy+e+Controle+de+Banda+%26%238211%3B+Parte+1" rel="nofollow" title="Adicionar ao&nbsp;Del.icio.us"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/delicious.png" title="Adicionar ao&nbsp;Del.icio.us" alt="Adicionar ao&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.gustavohenrique.net/brogui/2009/12/servidor-linux-com-proxy-e-controle-de-banda-parte-1/&amp;title=Servidor+Linux+com+Proxy+e+Controle+de+Banda+%26%238211%3B+Parte+1" rel="nofollow" title="Adicionar ao&nbsp;digg"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/digg.png" title="Adicionar ao&nbsp;digg" alt="Adicionar ao&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://www.gustavohenrique.net/brogui/2009/12/servidor-linux-com-proxy-e-controle-de-banda-parte-1/" rel="nofollow" title="Adicionar ao&nbsp;Facebook"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/facebook.png" title="Adicionar ao&nbsp;Facebook" alt="Adicionar ao&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://www.gustavohenrique.net/brogui/2009/12/servidor-linux-com-proxy-e-controle-de-banda-parte-1/&amp;title=Servidor+Linux+com+Proxy+e+Controle+de+Banda+%26%238211%3B+Parte+1" rel="nofollow" title="Adicionar ao&nbsp;Google Bookmarks"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/google.png" title="Adicionar ao&nbsp;Google Bookmarks" alt="Adicionar ao&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http://www.gustavohenrique.net/brogui/2009/12/servidor-linux-com-proxy-e-controle-de-banda-parte-1/&amp;bm_description=Servidor+Linux+com+Proxy+e+Controle+de+Banda+%26%238211%3B+Parte+1" rel="nofollow" title="Adicionar ao&nbsp;Mister Wong"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Adicionar ao&nbsp;Mister Wong" alt="Adicionar ao&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://www.gustavohenrique.net/brogui/2009/12/servidor-linux-com-proxy-e-controle-de-banda-parte-1/&amp;T=Servidor+Linux+com+Proxy+e+Controle+de+Banda+%26%238211%3B+Parte+1" rel="nofollow" title="Adicionar ao&nbsp;Netscape"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/netscape.png" title="Adicionar ao&nbsp;Netscape" alt="Adicionar ao&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://www.gustavohenrique.net/brogui/2009/12/servidor-linux-com-proxy-e-controle-de-banda-parte-1/&amp;title=Servidor+Linux+com+Proxy+e+Controle+de+Banda+%26%238211%3B+Parte+1" rel="nofollow" title="Adicionar ao&nbsp;reddit"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/reddit.png" title="Adicionar ao&nbsp;reddit" alt="Adicionar ao&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.gustavohenrique.net/brogui/2009/12/servidor-linux-com-proxy-e-controle-de-banda-parte-1/&amp;title=Servidor+Linux+com+Proxy+e+Controle+de+Banda+%26%238211%3B+Parte+1" rel="nofollow" title="Adicionar ao&nbsp;Stumble Upon"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Adicionar ao&nbsp;Stumble Upon" alt="Adicionar ao&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://www.gustavohenrique.net/brogui/2009/12/servidor-linux-com-proxy-e-controle-de-banda-parte-1/" rel="nofollow" title="Adicionar ao&nbsp;Technorati"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/technorati.png" title="Adicionar ao&nbsp;Technorati" alt="Adicionar ao&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http://www.gustavohenrique.net/brogui/2009/12/servidor-linux-com-proxy-e-controle-de-banda-parte-1/" rel="nofollow" title="Adicionar ao&nbsp;Tip'd"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/tipd.png" title="Adicionar ao&nbsp;Tip'd" alt="Adicionar ao&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Servidor+Linux+com+Proxy+e+Controle+de+Banda+%26%238211%3B+Parte+1+@+http://www.gustavohenrique.net/brogui/2009/12/servidor-linux-com-proxy-e-controle-de-banda-parte-1/" rel="nofollow" title="Adicionar ao&nbsp;Twitter"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/twitter.png" title="Adicionar ao&nbsp;Twitter" alt="Adicionar ao&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://www.gustavohenrique.net/brogui/2009/12/servidor-linux-com-proxy-e-controle-de-banda-parte-1/&amp;t=Servidor+Linux+com+Proxy+e+Controle+de+Banda+%26%238211%3B+Parte+1" rel="nofollow" title="Adicionar ao&nbsp;Yahoo My Web"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Adicionar ao&nbsp;Yahoo My Web" alt="Adicionar ao&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.gustavohenrique.net/brogui/2009/12/servidor-linux-com-proxy-e-controle-de-banda-parte-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
