# This file contains a list of all available settings and their default value for minetest.conf
# By default, all the settings are commented and not functional.
# Uncomment settings by removing the preceding #.
# minetest.conf is read by default from:
# ../minetest.conf
# ../../minetest.conf
# Any other path can be chosen by passing the path as a parameter
# to the program, eg. "minetest.exe --config ../minetest.conf.example".
# Further documentation:
# http://wiki.minetest.net/
#
# Client
#
## Controls
# If enabled, you can place blocks at the position (feet + eye level) where you stand.
# This is helpful when working with nodeboxes in small areas.
# type: bool
# enable_build_where_you_stand = false
# Player is able to fly without being affected by gravity.
# This requires the "fly" privilege on the server.
# type: bool
# free_move = false
# Fast movement (via use key).
# This requires the "fast" privilege on the server.
# type: bool
# fast_move = false
# If enabled together with fly mode, player is able to fly through solid nodes.
# This requires the "noclip" privilege on the server.
# type: bool
# noclip = false
# Smooths camera when moving and looking around.
# Useful for recording videos.
# type: bool
# cinematic = false
# Smooths rotation of camera. 0 to disable.
# type: float min: 0 max: 0.99
# camera_smoothing = 0.0
# Smooths rotation of camera in cinematic mode. 0 to disable.
# type: float min: 0 max: 0.99
# cinematic_camera_smoothing = 0.7
# Invert vertical mouse movement.
# type: bool
# invert_mouse = false
# Mouse sensitivity multiplier.
# type: float
# mouse_sensitivity = 0.2
# If enabled, "use" key instead of "sneak" key is used for climbing down and descending.
# type: bool
# aux1_descends = false
# Double-tapping the jump key toggles fly mode.
# type: bool
# doubletap_jump = false
# If disabled "use" key is used to fly fast if both fly and fast mode are enabled.
# type: bool
# always_fly_fast = true
# The time in seconds it takes between repeated right clicks when holding the right mouse button.
# type: float
# repeat_rightclick_time = 0.25
# Enable random user input (only used for testing).
# type: bool
# random_input = false
# Continuous forward movement (only used for testing).
# type: bool
# continuous_forward = false
# Key for moving the player forward.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
# type: key
# keymap_forward = KEY_KEY_W
# Key for moving the player backward.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
# type: key
# keymap_backward = KEY_KEY_S
# Key for moving the player left.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
# type: key
# keymap_left = KEY_KEY_A
# Key for moving the player right.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
# type: key
# keymap_right = KEY_KEY_D
# Key for jumping.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
# type: key
# keymap_jump = KEY_SPACE
# Key for sneaking.
# Also used for climbing down and descending in water if aux1_descends is disabled.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
# type: key
# keymap_sneak = KEY_LSHIFT
# Key for opening the inventory.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
# type: key
# keymap_inventory = KEY_KEY_I
# Key for moving fast in fast mode.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
# type: key
# keymap_special1 = KEY_KEY_E
# Key for opening the chat window.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
# type: key
# keymap_chat = KEY_KEY_T
# Key for opening the chat window to type commands.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
# type: key
# keymap_cmd = /
# Key for opening the chat console.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
# type: key
# keyman_console = KEY_F10
# Key for toggling unlimited view range.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
# type: key
# keymap_rangeselect = KEY_KEY_R
# Key for toggling flying.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
# type: key
# keymap_freemove = KEY_KEY_K
# Key for toggling fast mode.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
# type: key
# keymap_fastmove = KEY_KEY_J
# Key for toggling noclip mode.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
# type: key
# keymap_noclip = KEY_KEY_H
# Key for toggling cinematic mode.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
# type: key
# keymap_cinematic = KEY_F8
# Key for toggling display of minimap.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
# type: key
# keymap_minimap = KEY_F9
# Key for taking screenshots.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
# type: key
# keymap_screenshot = KEY_F12
# Key for dropping the currently selected item.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
# type: key
# keymap_drop = KEY_KEY_Q
# Key for toggling the display of the HUD.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
# type: key
# keymap_toggle_hud = KEY_F1
# Key for toggling the display of the chat.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
# type: key
# keymap_toggle_chat = KEY_F2
# Key for toggling the display of the fog.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
# type: key
# keymap_toggle_force_fog_off = KEY_F3
# Key for toggling the camrea update. Only used for development
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
# type: key
# keymap_toggle_update_camera =
# Key for toggling the display of debug info.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
# type: key
# keymap_toggle_debug = KEY_F5
# Key for toggling the display of the profiler. Used for development.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
# type: key
# keymap_toggle_profiler = KEY_F6
# Key for switching between first- and third-person camera.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
# type: key
# keymap_camera_mode = KEY_F7
# Key for increasing the viewing range. Modifies the minimum viewing range.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
# type: key
# keymap_increase_viewing_range_min = +
# Key for decreasing the viewing range. Modifies the minimum viewing range.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
# type: key
# keymap_decrease_viewing_range_min = -
# Key for printing debug stacks. Used for development.
# See http://irrlicht.sourceforge.net/docu/namespaceirr.html#a54da2a0e231901735e3da1b0edf72eb3
# type: key
# keymap_print_debug_stacks = KEY_KEY_P
## Network
# Address to connect to.
# Leave this blank to start a local server.
# Note that the address field in the main menu overrides this setting.
# type: string
# address =
# Port to connect to (UDP).
# Note that the port field in the main menu overrides this setting.
# type: int min: 1 max: 65535
# remote_port = 30000
# Save the map received by the client on disk.
# type: bool
# enable_local_map_saving = false
# Enable usage of remote media server (if provided by server).
# Remote servers offer a significantly faster way to download media (e.g. textures)
# when connecting to the server.
# type: bool
# enable_remote_media_server = true
# URL to the server list displayed in the Multiplayer Tab.
# type: string
# serverlist_url = servers.minetest.net
# File in client/serverlist/ that contains your favorite servers displayed in the Multiplayer Tab.
# type: string
# serverlist_file = favoriteservers.txt
## Graphics
### In-Game
#### Basic
# Whether to fog out the end of the visible area.
# type: bool
# enable_fog = true
# Enable a bit lower water surface, so it doesn't "fill" the node completely.
# Note that this is not quite optimized and that smooth lighting on the
# water surface doesn't work with this.
# type: bool
# new_style_water = false
# Leaves style:
# - Fancy: all faces visible
# - Simple: only outer faces, if defined special_tiles are used
# - Opaque: disable transparency
# type: enum values: fancy, simple, opaque
# leaves_style = fancy
# Connects glass if supported by node.
# type: bool
# connected_glass = false
# Enable smooth lighting with simple ambient occlusion.
# Disable for speed or for different looks.
# type: bool
# smooth_lighting = true
# Clouds are a client side effect.
# type: bool
# enable_clouds = true
# Use 3D cloud look instead of flat.
# type: bool
# enable_3d_clouds = true
#### Filtering
# Use mip mapping to scale textures. May slightly increase performance.
# type: bool
# mip_map = false
# Use anisotropic filtering when viewing at textures from an angle.
# type: bool
# anisotropic_filter = false
# Use bilinear filtering when scaling textures.
# type: bool
# bilinear_filter = false
# Use trilinear filtering when scaling textures.
# type: bool
# trilinear_filter = false
# Filtered textures can blend RGB values with fully-transparent neighbors,
# which PNG optimizers usually discard, sometimes resulting in a dark or
# light edge to transparent textures. Apply this filter to clean that up
# at texture load time.
# type: bool
# texture_clean_transparent = false
# When using bilinear/trilinear/anisotropic filters, low-resolution textures
# can be blurred, so automatically upscale them with nearest-neighbor
# interpolation to preserve crisp pixels. This sets the minimum texture size
# for the upscaled textures; higher values look sharper, but require more
# memory. Powers of 2 are recommended. Setting this higher than 1 may not
# have a visible effect unless bilinear/trilinear/anisotropic filtering is
# enabled.
# type: int
# texture_min_size = 64
# Pre-generate all item visuals used in the inventory.
# This increases startup time, but runs smoother in-game.
# The generated textures can easily exceed your VRAM, causing artifacts in the inventory.
# type: bool
# preload_item_visuals = false
# Experimental option, might cause visible spaces between blocks
# when set to higher number than 0.
# type: enum values: 0, 1, 2, 4, 8, 16
# fsaa = 0
#### Shaders
# Shaders allow advanced visul effects and may increase performance on some video cards.
# Thy only work with the OpenGL video backend.
# type: bool
# enable_shaders = true
##### Bumpmapping
# Enables bumpmapping for textures. Normalmaps need to be supplied by the texture pack
# or need to be auto-generated.
# Requires shaders to be enabled.
# type: bool
# enable_bumpmapping = false
# Enables on the fly normalmap generation (Emboss effect).
# Requires bumpmapping to be enabled.
# type: bool
# generate_normalmaps = false
# Strength of generated normalmaps.
# type: float
# normalmaps_strength = 0.6
# Defines sampling step of texture.
# A higher value results in smoother normal maps.
# type: int min: 0 max: 2
# normalmaps_smooth = 0
##### Parallax Occlusion
# Enables parallax occlusion mapping.
# Requires shaders to be enabled.
# type: bool
# enable_parallax_occlusion = false
# 0 = parallax occlusion with slope information (faster).
# 1 = relief mapping (slower, more accurate).
# type: int min: 0 max: 1
# parallax_occlusion_mode = 1
# Strength of parallax.
# type: float
# 3d_parallax_strength = 0.025
# Number of parallax occlusion iterations.
# type: int
# parallax_occlusion_iterations = 4
# Overall scale of parallax occlusion effect.
# type: float
# parallax_occlusion_scale = 0.08
# Overall bias of parallax occlusion effect, usually scale/2.
# type: float
# parallax_occlusion_bias = 0.04
##### Waving Nodes
# Set to true enables waving water.
# Requires shaders to be enabled.
# type: bool
# enable_waving_water = false
# type: float
# water_wave_height = 1.0
# type: float
# water_wave_length = 20.0
# type: float
# water_wave_speed = 5.0
# Set to true enables waving leaves.
# Requires shaders to be enabled.
# type: bool
# enable_waving_leaves = false
# Set to true enables waving plants.
# Requires shaders to be enabled.
# type: bool
# enable_waving_plants = false
#### Advanced
# Minimum wanted FPS.
# The amount of rendered stuff is dynamically set according to this. and viewing range min and max.
# type: int
# wanted_fps = 30
# If FPS would go higher than this, limit it by sleeping
# to not waste CPU power for no benefit.
# type: int
# fps_max = 60
# Maximum FPS when game is paused.
# type: int
# pause_fps_max = 20
# The allowed adjustment range for the automatic rendering range adjustment.
# Set this to be equal to viewing range minimum to disable the auto-adjustment algorithm.
# type: int
# viewing_range_nodes_max = 160
# The allowed adjustment range for the automatic rendering range adjustment.
# Set this to be equal to viewing range minimum to disable the auto-adjustment algorithm.
# type: int
# viewing_range_nodes_min = 35
# Vertical initial window size.
# type: int
# screenW = 800
# Horizontal initial window size.
# type: int
# screenH = 600
# Fullscreen mode.
# type: bool
# fullscreen = false
# Bits per pixel (aka color depth) in fullscreen mode.
# type: int
# fullscreen_bpp = 24
# Vertical screen synchronization.
# type: bool
# vsync = false
# Field of view in degrees.
# type: int min: 30 max: 160
# fov = 72
# Adjust the gamma encoding for the light tables. Lower numbers are brighter.
# This setting is for the client only and is ignored by the server.
# type: float min: 1 max: 3
# display_gamma = 1.8
# Path to texture directory. All textures are first searched from here.
# type: path
# texture_path =
# The rendering back-end for Irrlicht.
# type: enum values: null, software, burningsvideo, direct3d8, direct3d9, opengl
# video_driver = opengl
# Height on which clouds are appearing.
# type: int
# cloud_height = 120
# Radius of cloud area stated in number of 64 node cloud squares.
# Values larger than 26 will start to produce sharp cutoffs at cloud area corners.
# type: int
# cloud_radius = 12
# Multiplier for view bobbing.
# For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double.
# type: float
# view_bobbing_amount = 1.0
# Multiplier for fall bobbing.
# For example: 0 for no view bobbing; 1.0 for normal; 2.0 for double.
# type: float
# fall_bobbing_amount = 0.0
# 3D support.
# Currently supported:
# - none: no 3d output.
# - anaglyph: cyan/magenta color 3d.
# - interlaced: odd/even line based polarisation screen support.
# - topbottom: split screen top/bottom.
# - sidebyside: split screen side by side.
# type: enum values: none, anaglyph, interlaced, topbottom, sidebyside
# 3d_mode = none
# In-game chat console background color (R,G,B).
# type: string
# console_color = (0,0,0)
# In-game chat console background alpha (opaqueness, between 0 and 255).
# type: int min: 0 max: 255
# console_alpha = 200
# Selection box border color (R,G,B).
# type: string
# selectionbox_color = (0,0,0)
# Width of the selectionbox's lines around nodes.
# type: int min: 1 max: 5
# selectionbox_width = 2
# Crosshair color (R,G,B).
# type: string
# crosshair_color = (255,255,255)
# Crosshair alpha (opaqueness, between 0 and 255).
# type: int min: 0 max: 255
# crosshair_alpha = 255
# Whether node texture animations should be desynchronized per mapblock.
# type: bool
# desynchronize_mapblock_texture_animation = true
# Maximum proportion of current window to be used for hotbar.
# Useful if there's something to be displayed right or left of hotbar.
# type: float
# hud_hotbar_max_width = 1.0
# Enable selection highlighting for nodes (disables selectionbox).
# type: bool
# enable_node_highlighting = false
# Enables caching of facedir rotated meshes.
# type: bool
# enable_mesh_cache = false
# Enables minimap.
# type: bool
# enable_minimap = true
# Shape of the minimap. Enabled = round, disabled = square.
# type: bool
# minimap_shape_round = true
# True = 256
# False = 128
# Useable to make minimap smoother on slower machines.
# type: bool
# minimap_double_scan_height = true
# Make fog and sky colors depend on daytime (dawn/sunset) and view direction.
# type: bool
# directional_colored_fog = true
# The strength (darkness) of node ambient-occlusion shading.
# Lower is darker, Higher is lighter. The valid range of values for this
# setting is 0.25 to 4.0 inclusive. If the value is out of range it will be
# set to the nearest valid value.
# type: float min: 0.25 max: 4
# ambient_occlusion_gamma = 2.2
### Menus
# Use a cloud animation for the main menu background.
# type: bool
# menu_clouds = true
# Scale gui by a user specified value.
# Use a nearest-neighbor-anti-alias filter to scale the GUI.
# This will smooth over some of the rough edges, and blend
# pixels when scaling down, at the cost of blurring some
# edge pixels when images are scaled by non-integer sizes.
# type: float
# gui_scaling = 1.0
# When gui_scaling_filter is true, all GUI images need to be
# filtered in software, but some images are generated directly
# to hardware (e.g. render-to-texture for nodes in inventory).
# type: bool
# gui_scaling_filter = false
# When gui_scaling_filter_txr2img is true, copy those images
# from hardware to software for scaling. When false, fall back
# to the old scaling method, for video drivers that don't
# propery support downloading textures back from hardware.
# type: bool
# gui_scaling_filter_txr2img = true
# Delay showing tooltips, stated in milliseconds.
# type: int
# tooltip_show_delay = 400
# Whether freetype fonts are used, requires freetype support to be compiled in.
# type: bool
# freetype = true
# Path to TrueTypeFont or bitmap.
# type: path
# font_path = fonts/liberationsans.ttf
# type: int
# font_size = 15
# Font shadow offset, if 0 then shadow will not be drawn.
# type: int
# font_shadow = 1
# Font shadow alpha (opaqueness, between 0 and 255).
# type: int min: 0 max: 255
# font_shadow_alpha = 128
# type: path
# mono_font_path = fonts/liberationmono.ttf
# type: int
# mono_font_size = 15
# This font will be used for certain languages.
# type: path
# fallback_font_path = fonts/DroidSansFallbackFull.ttf
# type: int
# fallback_font_size = 15
# type: int
# fallback_font_shadow = 1
# type: int min: 0 max: 255
# fallback_font_shadow_alpha = 128
# Path to save screenshots at.
# type: path
# screenshot_path =
### Advanced
# Adjust dpi configuration to your screen (non X11/Android only) e.g. for 4k screens.
# type: int
# screen_dpi = 72
## Sound
# type: bool
# enable_sound = true
# type: float min: 0 max: 1
# sound_volume = 0.7
## Advanced
# Timeout for client to remove unused map data from memory.
# type: int
# client_unload_unused_data_timeout = 600
# Maximum number of mapblocks for client to be kept in memory.
# Set to -1 for unlimited amount.
# type: int
# client_mapblock_limit = 5000
# Whether to show the client debug info (has the same effect as hitting F5).
# type: bool
# show_debug = false
#
# Server / Singleplayer
#
# Name of the server, to be displayed when players join and in the serverlist.
# type: string
# server_name = Minetest server
# Description of server, to be displayed when players join and in the serverlist.
# type: string
# server_description = mine here
# Domain name of server, to be displayed in the serverlist.
# type: string
# server_address = game.minetest.net
# Homepage of server, to be displayed in the serverlist.
# type: string
# server_url = http://minetest.net
# Automaticaly report to the serverlist.
# type: bool
# server_announce = false
# Announce to this serverlist.
# If you want to announce your ipv6 address, use serverlist_url = v6.servers.minetest.net.
# type: string
# serverlist_url = servers.minetest.net
## Network
# Network port to listen (UDP).
# This value will be overridden when starting from the main menu.
# type: int
# port = 30000
# The network interface that the server listens on.
# type: string
# bind_address =
# Enable to disallow old clients from connecting.
# Older clients are compatible in the sense that they will not crash when connecting
# to new servers, but they may not support all new features that you are expecting.
# type: bool
# strict_protocol_version_checking = false
# Specifies URL from which client fetches media instead of using UDP.
# $filename should be accessible from $remote_media$filename via cURL
# (obviously, remote_media should end with a slash).
# Files that are not present will be fetched the usual way.
# type: string
# remote_media =
# Enable/disable running an IPv6 server. An IPv6 server may be restricted
# to IPv6 clients, depending on system configuration.
# Ignored if bind_address is set.
# type: bool
# ipv6_server = false
### Advanced
# How many blocks are flying in the wire simultaneously per client.
# type: int
# max_simultaneous_block_sends_per_client = 10
# How many blocks are flying in the wire simultaneously for the whole server.
# type: int
# max_simultaneous_block_sends_server_total = 40
# To reduce lag, block transfers are slowed down when a player is building something.
# This determines how long they are slowed down after placing or removing a node.
# type: float
# full_block_send_enable_min_time_from_building = 2.0
# Maximum number of packets sent per send step, if you have a slow connection
# try reducing it, but don't reduce it to a number below double of targeted
# client number.
# type: int
# max_packets_per_iteration = 1024
## Game
# Default game when creating a new world.
# This will be overridden when creating a world from the main menu.
# type: string
# default_game = minetest
# Message of the day displayed to players connecting.
# type: string
# motd =
# Maximum number of players that can connect simultaneously.
# type: int
# max_users = 15
# World directory (everything in the world is stored/*
Minetest
Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "clientmedia.h"
#include "httpfetch.h"
#include "client.h"
#include "filecache.h"
#include "filesys.h"
#include "log.h"
#include "porting.h"
#include "settings.h"
#include "util/hex.h"
#include "util/serialize.h"
#include "util/sha1.h"
#include "util/string.h"
static std::string getMediaCacheDir()
{
return porting::path_cache + DIR_DELIM + "media";
}
/*
ClientMediaDownloader
*/
ClientMediaDownloader::ClientMediaDownloader():
m_media_cache(getMediaCacheDir()),
m_httpfetch_caller(HTTPFETCH_DISCARD)
{
}
ClientMediaDownloader::~ClientMediaDownloader()
{
if (m_httpfetch_caller != HTTPFETCH_DISCARD)
httpfetch_caller_free(m_httpfetch_caller);
for (auto &file_it : m_files)
delete file_it.second;
for (auto &remote : m_remotes)
delete remote;
}
void ClientMediaDownloader::addFile(const std::string &name, const std::string &sha1)
{
assert(!m_initial_step_done); // pre-condition
// if name was already announced, ignore the new announcement
if (m_files.count(name) != 0) {
errorstream << "Client: ignoring duplicate media announcement "
<< "sent by server: \"" << name << "\""
<< std::endl;
return;
}
// if name is empty or contains illegal characters, ignore the file
if (name.empty() || !string_allowed(name, TEXTURENAME_ALLOWED_CHARS)) {
errorstream << "Client: ignoring illegal file name "
<< "sent by server: \"" << name << "\""
<< std::endl;
return;
}
// length of sha1 must be exactly 20 (160 bits), else ignore the file
if (sha1.size() != 20) {
errorstream << "Client: ignoring illegal SHA1 sent by server: "
<< hex_encode(sha1) << " \"" << name << "\""
<< std::endl;
return;
}
FileStatus *filestatus = new FileStatus();
filestatus->received = false;
filestatus->sha1 = sha1;
filestatus->current_remote = -1;
m_files.insert(std::make_pair(name, filestatus));
}
void ClientMediaDownloader::addRemoteServer(const std::string &baseurl)
{
assert(!m_initial_step_done); // pre-condition
#ifdef USE_CURL
if (g_settings->getBool("enable_remote_media_server")) {
infostream << "Client: Adding remote server \""
<< baseurl << "\" for media download" << std::endl;
RemoteServerStatus *remote = new RemoteServerStatus();
remote->baseurl = baseurl;
remote->active_count = 0;
m_remotes.push_back(remote);
}
#else
infostream << "Client: Ignoring remote server \""
<< baseurl << "\" because cURL support is not compiled in"
<< std::endl;
#endif
}
void ClientMediaDownloader::step(Client *client)
{
if (!m_initial_step_done) {
initialStep(client);
m_initial_step_done = true;
}
// Remote media: check for completion of fetches
if (m_httpfetch_active) {
bool fetched_something = false;
HTTPFetchResult fetch_result;
while (httpfetch_async_get(m_httpfetch_caller, fetch_result)) {
m_httpfetch_active--;
fetched_something = true;
// Is this a hashset (index.mth) or a media file?
if (fetch_result.request_id < m_remotes.size())
remoteHashSetReceived(fetch_result);
else
remoteMediaReceived(fetch_result, client);
}
if (fetched_something)
startRemoteMediaTransfers();
// Did all remote transfers end and no new ones can be started?
// If so, request still missing files from the minetest server
// (Or report that we have all files.)
if (m_httpfetch_active == 0) {
if (m_uncached_received_count < m_uncached_count) {
infostream << "Client: Failed to remote-fetch "
<< (m_uncached_count-m_uncached_received_count)
<< " files. Requesting them"
<< " the usual way." << std::endl;
}
startConventionalTransfers(client);
}
}
}
void ClientMediaDownloader::initialStep(Client *client)
{
// Check media cache
m_uncached_count = m_files.size();
for (auto &file_it : m_files) {
std::string name = file_it.first;
FileStatus *filestatus = file_it.second;
const std::string &sha1 = filestatus->sha1;
std::ostringstream tmp_os(std::ios_base::binary);
bool found_in_cache = m_media_cache.load(hex_encode(sha1), tmp_os);
// If found in cache, try to load it from there
if (found_in_cache) {
bool success = checkAndLoad(name, sha1,
tmp_os.str